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

Gui only pops up once and not everytime... problem (?)

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        hit.Parent.HumanoidRootPart.CFrame = workspace:FindFirstChild("CC").CFrame
        if player.PlayerGui.CafeTeleport.Frame.Visible == false then
	player.PlayerGui.CafeTeleport.Frame.Visible = true
  end 
 end
end)

Problem is that the gui only pops up the first time and doesnt pop up everytime the player touches the door.... Im confused on why this is happening since i added the check part "if" so it checks if its false then sets the value to true.

This is a server script.

2 comments

0

Is this local or global script

0

global ^^

1 answer

✓ Accepted answer

You're only writing a conditional statement for one condition, not two.

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		hit.Parent.HumanoidRootPart.CFrame = workspace:FindFirstChild("CC").CFrame
		if player.PlayerGui.CafeTeleport.Frame.Visible == false then
			player.PlayerGui.CafeTeleport.Frame.Visible = true
		else
			player.PlayerGui.CafeTeleport.Frame.Visible = false
		end
	end
end)

The above code will toggle the Visible property of the Frame.

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