Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Hello i need help on a tool giving gui?

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)

1 comment

0

Is this a Script or a LocalScript?

1 answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.