i have a script that when they touch a certain part a GUI appears on their screen. and the same for whe they leave the part but the GUI goes away. When i go to test it, it appears but it then goes away and doesnt come back... and whenever they sit in a chair it goes away. why?
This is a server script in the workspace
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid")then
if game.Players[hit.Parent.Name].Name == script.Parent.Owner.Value then
game:GetService("ReplicatedStorage").RemoteEvents.Workplace1JobEvent:FireServer()
end
end
end)
script.Parent.TouchEnded:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if game.Players[hit.Parent.Name].Name == script.Parent.Owner.Value then
game:GetService("ReplicatedStorage").RemoteEvents.Workplace1JobEvent.End:FireServer()
end
end
end)
this is a Local Script inside of the player scripts
game:GetService("ReplicatedStorage").RemoteEvents.Workplace1JobEvent.OnServerEvent:Connect(function(plr)
print(plr)
local gui = game.Players.LocalPlayer.PlayerGui.ShopGui.Workplace1
if game.Players.LocalPlayer.PlayerGui.ShopGui.Workplace1.Started.Value == false then
gui.Started.Value = true
gui.Visible = true
gui.Needed.Value = math.random(250,600)
gui.Current.Value = 0
else
gui.Started.Value = true
end
return
end)
game:GetService("ReplicatedStorage").RemoteEvents.Workplace1JobEvent.End.OnServerEvent:Connect(function(plr)
game.Players.LocalPlayer.PlayerGui.ShopGui.Workplace1.Visible = false
return
end)
if anyone is able to help me with this i would really appreciate it, i have been struggling with it for hours now.
Edit: the problem is with the .TouchEnded part because something is triggering it and im not sure what.

3 comments
ok, a few things. you're using OnServerEvent in both the server script and the local script. i'm pretty sure you're only supposed to use OnServerEvent from a server script.
so in the local script i should change it to on client event?
it's also really hard for me to see what's going on and understand what's happening. i'd recommend keeping the code clean and giving more structural context