#17:02:50.609 ServerScriptService.Server.Room.Item:59: attempt to index nil with 'Pivot' - Server

1 messages · Page 1 of 1 (latest)

tulip sigil
#

Im getting this error but I have a pivot in my Key and coin so idk why it giving me this error

#

anyone plz

paper trail
#

Show code

tulip sigil
# paper trail 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

paper trail
#

did you parent newmodel?

tulip sigil
#

yea

paper trail
tulip sigil
#

yea

paper trail
tulip sigil
#

59

tulip sigil
#

local pivotAttachment = newModel.PrimaryPart.Pivot

paper trail
tulip sigil
#

k

tulip sigil
#

@paper trail

tulip sigil
#

@paper trail you there

tulip sigil
#

@paper trail

paper trail
tulip sigil
paper trail
#

new model

tulip sigil
#

in the script orrr

tulip sigil
paper trail
tulip sigil
#

Ummm well I used a a tutoiral but they hadn't reply to me and I send it over 3 months ago

tulip sigil
radiant eagle
tulip sigil
#

I ask them 3 months ago no one had replyed it only untill yesterday I remember I had this game

weak roverBOT
#

studio** You are now Level 9! **studio

tulip sigil
#

and even making a new one didn't work no one still replyed

tulip sigil
radiant eagle
tulip sigil
#

what line

radiant eagle
#

I don't know where the line is, since you didn't set it anywhere

tulip sigil
#

wait so what is the line above it

radiant eagle
#

but you created it with Instance.new("Model")

#

It's an if statement

tulip sigil
#

it hard to know where to put it without knowing

tulip sigil
radiant eagle
#

If you used a tutorial, try to find what you're missing

tulip sigil
#

I have even went back to old verison didn't work still

radiant eagle
tulip sigil
#

ok so what do I add under it

radiant eagle
#

What do you think is the primary part?

tulip sigil
#

newModel

radiant eagle
#

If so, set it to that

radiant eagle
tulip sigil
#

22:17:53.179 Unable to create an Instance of type "newModel" - Server - Item:35

#

so not newmodel

radiant eagle
#

did you even try watching any scripting tutorial

tulip sigil
#

no

#

I watch them then forgets them

tulip sigil
radiant eagle
#

Oh I understand the problem now

#

I didn't read the whole thing

#

Your tools don't have an object named "Handle" in them

tulip sigil
#

what coin and Key

radiant eagle
#

I say all of them should

tulip sigil
#

you don't hold the coin don't you

radiant eagle
#

send a screenshot of the tools in explorer

tulip sigil
radiant eagle
tulip sigil
#

I got a coin that isn't a Holder

radiant eagle
#

I say name that Part to Handle

tulip sigil
#

Didn't work

tulip sigil
tulip sigil
radiant eagle
tulip sigil
#

fly high

#

but whar are we going to do

tulip sigil
tulip sigil
#

@radiant eagle are you here

tulip sigil
#

@radiant eagle

#

are you here

tulip sigil
haughty frigate
#

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

radiant eagle
tulip sigil
#

oh

#

I fix it but there more errors

radiant eagle
#

But yeah I was stumped

tulip sigil
#

its alr

radiant eagle
#

I suggest ping a helper wizard in the server

tulip sigil
#

Wizard?

radiant eagle
#

in GnomeCode's server

tulip sigil
#

Oh I got some help but then they told me to do it myself after the new error

radiant eagle
tulip sigil
#

to do it myself

radiant eagle
#

well I didn't see you ping one

tulip sigil
radiant eagle
#

one with the helper wizard role

tulip sigil
#

wait isn't that the owner with the wizard or

radiant eagle
tulip sigil
#

so he's useless

paper trail
# tulip sigil

bro he walked you step by step not everyone has a full 24 hrs to help you