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

Trying to make a localscript tthat makes a frame visible when equipped, why won't this work?

Trying to make a localscript tthat makes a frame visible when equipped, and it goes away when unequipped. The local script is inside the tool. The screen gui is ToolGui that is in startergui and the frame is in ToolGui.

Script:

if tool.equipped = true then
	StarterGui.ToolGui.Frame.Visible = true
	if tool.equipped = false then return nil
end

This script might be dumb, I'm new to scripting.This script is just stuff that I learned from other people that tweaked my other scripts.

2 answers

✓ Accepted answer

you cant use StarterGui.

instead do this:

local plr = game.Players.LocalPlayer
local frame = plr.PlayerGui:WaitForChild("ToolGui"):WaitForChild("Frame")
local tool = script.Parent

tool.Equipped:Connect(function()
	frame.Visible = true
end)

--lets make it so that you cant see the frame anymore once the player unequipped the tool.

tool.Unequipped:Connect(function()
	frame.Visible = false
end)

tell me if there are any errors!

also make sure the script is a local script.

1 comment

0

Stonks

Hey, I noticed a few errors in your script that might be causing it to not work.

Here is the revised version with notes:

if tool.Equipped = true then --.Equipped was lowercase
	game.StarterGui.ToolGui.Frame.Visible = true --you didn't define what starter gui was under. (game)
	if tool.Equipped = false then return nil --Equipped was lowercase yet again

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