I made a script where when you touch a block you get a sword and all ui visibility goes invisible and I made another block when you leave only 3 ui get visible but not the rest but the frames rent turning invis, the scripts are below. What am I doing wrong?
Give swordand ui invisible script
script.Parent.Touched:Connect(function(hit) -- The part has been touched
if hit.Parent:FindFirstChild("Humanoid") then -- The touched's parent has a humanoid in it
local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- Getting the player by the character (the hit.Parent is our player in this case)
local weapon = game:GetService("ReplicatedStorage"):FindFirstChild("ClassicSword")
local mewgui = player.PlayerGui.resetonspawn.MewClick
local pushupcui = player.PlayerGui.resetonspawn.PushUpClick
local squintclick = player.PlayerGui.resetonspawn.SquintClick
local mewselect1 = player.PlayerGui.resetonspawn.MewSelect1
local mewselect2 = player.PlayerGui.resetonspawn.MewSelect2
local pushupselect1 = player.PlayerGui.resetonspawn.PushUpSelect1
local pushupselect2 = player.PlayerGui.resetonspawn.PushUpSelect2
local squintselect1 = player.PlayerGui.resetonspawn.SquintSelect1
local squintselect2 = player.PlayerGui.resetonspawn.SquintSelect2
if player then -- If the player is here
game.ReplicatedStorage.weapongive:FireClient(player) -- Put in the event name your remote event's name, this fires the event.
mewgui.Visible = false
pushupcui.Visible = false
squintclick.Visible = false
mewselect1.Visible = false
mewselect2.Visible = false
pushupselect1.Visible = false
pushupselect2.Visible = false
squintselect1.Visible = false
squintselect2.Visible = false
local Find = player.Backpack:FindFirstChild("ClassicSword")
if not Find then
local find1 = player.Character:FindFirstChild("ClassicSword")
if not find1 then
weapon:Clone().Parent = player.Backpack
end
end
end
end
end)
destroy sword script and only 3 UI reappear
script.Parent.Touched:Connect(function(hit) -- The part has been touched
if hit.Parent:FindFirstChild("Humanoid") then -- The touched's parent has a humanoid in it
local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- Getting the player by the character (the hit.Parent is our player in this case)
local mewgui = player.PlayerGui.resetonspawn.MewClick
local pushupcui = player.PlayerGui.resetonspawn.PushUpSelect1
local squintgui = player.PlayerGui.resetonspawn.SquintSelect2
local pushclick = player.PlayerGui.resetonspawn.PushUpClick
local pushselect2 = player.PlayerGui.resetonspawn.PushUpSelect2
local squintclick = player.PlayerGui.resetonspawn.SquintClick
local squintselect1 = player.PlayerGui.resetonspawn.SquintSelect1
local mewselect1 = player.PlayerGui.resetonspawn.MewSelect1
local mewselect2 = player.PlayerGui.resetonspawn.MewSelect2
if player then -- If the player is here
game.ReplicatedStorage.weapontake:FireClient(player) -- Put in the event name your remote event's name, this fires the event.
mewgui.Visible = true
pushupcui.Visible = true
squintgui.Visible = true
pushclick.Visible = false
pushselect2.Visible = false
squintclick.Visible = false
squintselect1.Visible = false
mewselect1.Visible = false
mewselect2.Visible = false
local Find = player.Backpack:FindFirstChild("ClassicSword")
if Find then
Find:Destroy()
end
local Find1 = player.Character:FindFirstChild("ClassicSword")
if Find1 then
Find1:Destroy()
end
end
end
end)