Ad
Log in to vote
0

Problem with my gun script (gui cloning)?

Asked by
Relatch 550 Moderation Voter
4 years ago

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.

0
Is this in a LocalScript? Overdash 995 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

try adding a

wait(1)

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

0
wait(1) is enough time for scripts to load the tool marcoantoniosantos3 200 — 4y
Ad
Log in to vote
1
Answered by 4 years ago

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.

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

Answer this question