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

Hello i need help on a tool giving gui?

Asked by
Subbix -5
9 years ago

The problem is it keeps telling me the parent is locked. Please notie the coregui's are removed so it goes to character and works only if i copy and paste it in the character.

tools = "Bronze Sword"
plr = game:GetService("Players")
gui = plr.LocalPlayer.PlayerGui
function onClick()
    tool = game:GetService("ReplicatedStorage")
    tool:FindFirstChild(tools):clone()
    tool.Parent = plr.LocalPlayer.Character
end
script.Parent.MouseButton1Down:connect(onClick)
0
Is this a Script or a LocalScript? BlueTaslem 18071 — 9y

1 answer

Log in to vote
0
Answered by
Ekkoh 635 Moderation Voter
9 years ago

It's saying the Parent property is locked because you set the tool variable to ReplicatedStorage, and the parent of that is Game. For this to make more sense, I'd do something like this.

toolName = "Bronze Sword"
plr = game:GetService("Players").LocalPlayer
repStore = Game:GetService("ReplicatedStorage")

function onClick()
    tool = repStore:FindFirstChild(toolName):Clone()
    tool.Parent = plr.Character -- maybe plr.Backpack?
end
script.Parent.MouseButton1Down:connect(onClick)

Ad

Answer this question