How to fix this touching function script?

Hi,
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")

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

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