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.
1 | tools = "Bronze Sword" |
2 | plr = game:GetService( "Players" ) |
3 | gui = plr.LocalPlayer.PlayerGui |
4 | function onClick() |
5 | tool = game:GetService( "ReplicatedStorage" ) |
6 | tool:FindFirstChild(tools):clone() |
7 | tool.Parent = plr.LocalPlayer.Character |
8 | end |
9 | script.Parent.MouseButton 1 Down:connect(onClick) |
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.
1 | toolName = "Bronze Sword" |
2 | plr = game:GetService( "Players" ).LocalPlayer |
3 | repStore = Game:GetService( "ReplicatedStorage" ) |
4 |
5 | function onClick() |
6 | tool = repStore:FindFirstChild(toolName):Clone() |
7 | tool.Parent = plr.Character -- maybe plr.Backpack? |
8 | end |
9 | script.Parent.MouseButton 1 Down:connect(onClick) |