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

How come the else has a problem in this script?

So for some reason I can't get "else" to work here I think you have to have it as an "if" but I don't know how to put if that way. Can anyone help?

local Gun1 = game.ServerStorage.Gun1
local Gun2 = game.ServerStorage.Gun2
local GunGUI1 = game.StarterGUI.ScreenGUI.Frame.Gun1
local GunGUI2 = game.StarterGui.ScreenGui.Frame.Gun2
local Equipped = false

Gun1.Equipped:connect(function()
	GunGUI1.Visible = false
	GunGUI2.Visible = false
else
	GunGUI1.Visible = true
	GunGUI2.Visible = true
end)

2 answers

✓ Accepted answer

In your code, you have attempted to use an Else statement in a Function in order to fix this, we must use the Unequipped on the Tool

local Gun1 = game.ServerStorage.Gun1
local Gun2 = game.ServerStorage.Gun2
local GunGUI1 = game.StarterGUI.ScreenGUI.Frame.Gun1
local GunGUI2 = game.StarterGui.ScreenGui.Frame.Gun2
local Equipped = false

Gun1.Equipped:connect(function()
	    GunGUI1.Visible = false
	    GunGUI2.Visible = false
end)

Gun1.Unequipped:connect(function()
	GunGUI1.Visible = true
	GunGUI2.Visible = true
end)

You can read all about these at these ROBLOX wiki pages:

http://wiki.roblox.com/index.php?title=API:Class/Tool/Equipped

http://wiki.roblox.com/index.php?title=API:Class/Tool/Unequipped

If you need anymore help PM me on ROBLOX here:

https://www.roblox.com/messages/compose?recipientId=18982229

~ Taryo

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