How to fix this touching function script?

I have script that shows the GUI if player touches it, but when im no more touching it and then touch it, it dont show the gui. I have no errors so i dont know how to fix it

Script inside the part:

local Players = game:GetService("Players")

	local character = hit.Parent
	local player = Players:GetPlayerFromCharacter(hit.Parent)
	if not player then return end
	local hum = character:FindFirstChild("Humanoid")
	hum.WalkSpeed = 0
	hum.JumpPower = 0
	player.PlayerGui.GUI.Enabled = false
	if not player.PlayerGui:FindFirstChild("MyGUI") then
		game.ReplicatedStorage.MyGUI:Clone().Parent = player.PlayerGui	    

Where do you delete the GUI? On the client side or server?

1 Like

in local script so in client side

That’s why the server thinks you have a GUI in PlayerGui. Because if you check server side you will find a GUI inside your PlayerGui but in the client is not going to show up because you deleted a GUI on a local script. You will have to use RemoteEvents and destroy the GUI on the server script.

1 Like