Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Im trying to get a GUI to show when I hold a tool, its not working. Any fixes?

Asked by 4 years ago

I don't know why it isn't working

local Player = game:GetService("Players").LocalPlayer

local Tool = game.StarterPack.HighPad

Tool.Equipped:Connect(function()
    Player.PlayerGui.Tablet.OuterBody.Visible = true
    Player.PlayerGui.Tablet.OuterBody.Active = true
end)

Tool.Unequipped:Connect(function()
    Player.PlayerGui.Tablet.OuterBody.Visible = false
    Player.PlayerGui.Tablet.OuterBody.Active = false
end)

2 answers

Log in to vote
0
Answered by 4 years ago

Put your gui in the tool. Then put this script in the tool:

script.Parent.Equipped:Connect(function()
     player = game.Players:FindFirstChild(script.Parent.Parent.Name)
     gui = script.Parent:FindFirstChild("GuiName"):Clone().Parent = game.Players:FindFirstChild(script.Parent.Parent.Name)
end)

script.Parent.Unequipped:Connect(function()
     game.Players[player].PlayerGui.GuiName:Destroy()
end)

This should fix your problem. If it doesn't, the output from this script in ROBLOX Studio should say something that is easy enough to understand and help you fix the issue.

Ad
Log in to vote
2
Answered by 4 years ago

You are connecting the function to the Equipped signal of the tool in StarterPack. When the player spawns, the tool will be cloned into the player's backpack but the script will continue to listen for when the tool which is in StarterPack is equipped. To fix this, you could put the script under the tool and replace this line

local Tool = game.StarterPack.HighPad

with this

local Tool = script.Parent
0
Sadly, I have tried this before but it hasn't been working. TotalElevation 45 — 4y

Answer this question