Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can someone tell what is wrong with this?

Asked by
Eppobot 13
8 years ago

So i tried to make a button, that gives you weapon from Lighting if it is not already in you backpack. But as usually it is not working. Can someone tell me what is wrong with this.

So it is part. Inside that part is this script, StringValue named Value and ClickDetector. There is tool called "Key" in Lighting. StringValue value is "Key".

function onClicked(Player)
    local found = Player.Backpack:FindFirstChild((script.Parent.Value.Value))
    if not found then 
        local Item=game.Lighting(script.Parent.Value.Value):Clone()
        Item.Parent=Player.Backpack
    end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 answer

Log in to vote
0
Answered by 8 years ago

Instead of

local Item=game.Lighting(script.Parent.Value.Value):Clone()

Use this instead? I don't see any errors in the script.

local Item=game.Lighting:WaitForChild(script.Parent.Value.Value):Clone()
Ad

Answer this question