#17:02:50.609 ServerScriptService.Server.Room.Item:59: attempt to index nil with 'Pivot' - Server
1 messages · Page 1 of 1 (latest)
Show code
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local item = {}
function item.Interact(player, prompt, template, itemName)
if player.Character then
if itemName == "Key" then
local tool = ReplicatedStorage.Assets.Items.Key:Clone()
tool.Parent = player.Character
tool.Handle.KeyJingle:Play()
elseif itemName == "Coin" then
local sound = script.Coin_Pickup:Clone()
sound.PlayOnRemove = true
sound.Parent = player.Character.Head
sound.Parent = nil
player.leaderstats.Coins.Value += 1
end
prompt.Enabled = false
template:Destroy()
end
end
function item.New(location, itemName)
local itemObject = ReplicatedStorage.Assets.Items:FindFirstChild(itemName)
if not itemObject then
warn("No such item")
return
end
local newModel = nil
if itemObject:IsA("Tool") then
newModel = Instance.new("Model")
newModel.Name = itemObject.Name
for i, obj in itemObject:GetChildren() do
local clone = obj:Clone()
if clone.Name == "Handle" then
newModel.PrimaryPart = clone
end
clone.Parent = newModel
end
for i, obj in newModel:GetDescendants() do
if obj == newModel.PrimaryPart then continue end
if not obj:IsA("BasePart") then continue end
local weld = Instance.new("WeldConstraint")
weld.Part0 = obj
weld.Part1 = newModel.PrimaryPart
weld.Parent = obj
end
elseif itemObject:IsA("Model") then
newModel = itemObject:Clone()
end
local pivotAttachment = newModel.PrimaryPart.Pivot
local offset = location.WorldCFrame * pivotAttachment.WorldCFrame:Inverse()
newModel.Parent = location
newModel:PivotTo(offset * newModel.PrimaryPart.CFrame)
local weld = Instance.new("WeldConstraint")
weld.Part0 = newModel.PrimaryPart
weld.Part1 = location.Parent
weld.Parent = newModel.PrimaryPart
local prompt = Instance.new("ProximityPrompt")
prompt.ActionText = ""
prompt.MaxActivationDistance = 5
prompt.Parent = location
prompt.Triggered:Connect(function(player)
item.Interact(player, prompt, newModel, itemName)
end)
end
return item
its saying it new model doesnt exist
did you parent newmodel?
yea
does newmodel have a primarypart
yea
which line is it having the error
59
Where is 59
local pivotAttachment = newModel.PrimaryPart.Pivot
yeah its saying it dont got primarypart
k
@paper trail you there
@paper trail
make it have a primary part
but which model
new model
well I dont have a new model so hmmm
bro u created it in the script
Ummm well I used a a tutoiral but they hadn't reply to me and I send it over 3 months ago
so what should I do
You have a better chance in the Gnomeland server
I ask them 3 months ago no one had replyed it only untill yesterday I remember I had this game
** You are now Level 9! **
and even making a new one didn't work no one still replyed
so whats my hope if no one reply
Something is missing, you never set the PrimaryPart of the created model newModel
what line
I don't know where the line is, since you didn't set it anywhere
wait so what is the line above it
it hard to know where to put it without knowing
if itemObject:IsA("Tool") then this one
If you used a tutorial, try to find what you're missing
I have even went back to old verison didn't work still
yeah that's the line above it
ok so what do I add under it
What do you think is the primary part?
newModel
If so, set it to that
That's the model
22:17:53.179 Unable to create an Instance of type "newModel" - Server - Item:35
so not newmodel
😭
did you even try watching any scripting tutorial
should I look what he has for his line
Oh I understand the problem now
I didn't read the whole thing
Your tools don't have an object named "Handle" in them
what coin and Key
I say all of them should
you don't hold the coin don't you
send a screenshot of the tools in explorer
That's the only item?
I say name that Part to Handle
Didn't work
so ummmmm what should we do now
u there
no I'm dead
is it having to do with the model or the script
@radiant eagle Bro I have 35 minutes before im logging off
jfc u gotta stop pinging everyone like 20 times when they don’t respond
cyrus has given you all the information you need to fix your issue
I had to log off too 😭
But yeah I was stumped
its alr
I suggest ping a helper wizard in the server
Wizard?
in GnomeCode's server
Oh I got some help but then they told me to do it myself after the new error
A helper wizard told you that?
to do it myself
I checked out your post, I didn't see one
well I didn't see you ping one
one with the helper wizard role
wait isn't that the owner with the wizard or
that's just a member
so he's useless
bro he walked you step by step not everyone has a full 24 hrs to help you