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

Problem with my gun script (gui cloning)?

Well, it works fine in studio mode, but not in-game. In-game, I get the error FiringModeGui is not a valid member of Tool. And before you ask, yes FiringModeGui is inside the tool. When the tool is equipped, I want it to show the gui.

tool = script.Parent
gui = tool.FiringModeGui:Clone()
plr = game.Players.LocalPlayer

tool.Equipped:connect(function(mse)
	gui.Parent = plr.PlayerGui
end)

The script above is a part of the script that clones it. When equipped, it sends the gui into the players PlayerGui.

1 comment

0

Is this in a LocalScript?

2 answers

✓ Accepted answer

try adding a

wait(1)

at code start (line 1). Hope this helps! If not tell output... ~marcoantoniosantos3

1 comment

0

wait(1) is enough time for scripts to load the tool

Try this.

tool = script.Parent
gui = tool.FiringModeGui
plr = game.Players.LocalPlayer

tool.Equipped:connect(function(mse)
	wait(1)
	gui:Clone().Parent = plr.PlayerGui
end)

I dont put clones into the locals, put it into the base script.

1 comment

0

adding wait(1) below tool.Equipped will not help at all, because if you read his error, it's at tool.FiringModeGui.

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