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
10 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.

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

1 answer

Log in to vote
0
Answered by
Ekkoh 635 Moderation Voter
10 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.

1toolName = "Bronze Sword"
2plr = game:GetService("Players").LocalPlayer
3repStore = Game:GetService("ReplicatedStorage")
4 
5function onClick()
6    tool = repStore:FindFirstChild(toolName):Clone()
7    tool.Parent = plr.Character -- maybe plr.Backpack?
8end
9script.Parent.MouseButton1Down:connect(onClick)
Ad

Answer this question