so, im not sure if roblox studio had an update or anything but, i use to use theys script were if you click something the gui pops up on only your screen, because i was using a local script, but i tryd useing a player tough event and it worked it popes up on my screen if you touch a part, but the thing was it popes up on everyone screen when only 1 person touches the part, even tho im making it in a local script it seems to be acting like a normal script
this is the script i used for the player touch event, do you know whats wrong with it?
How did you infer that, did you try it in game with other players?
You can make it so touching it each time toggles the state by doing
thing.Touched:Connect(function()
script.Parent.Enabled = not script.Parent.Enabled
end)
You should add some sort of cooldown too for either way (toggle or just setting it to Enabled = true when touched) to prevent code running unnecessarily too often.
?? This reply was made to address some details in the post only.
The problem is that the Touched event doesn’t fire when the player’s character touches the part, it fires when any BasePart touches it. All clients can see all parts touching each other, so what you have to do is check if the part that touched is a descendant of a player’s character and check if the player is the LocalPlayer.
script.Parent.Enabled = false
local thing = game.Workspace.Store.Touch
thing.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit:FindFirstAncestorOfClass("Model"))
if player and player == game.Players.LocalPlayer then
script.Parent.Enabled = true
end
end)
It’s meant to pop up for everyone. Your script makes the thing pop up whenever anything touches it. So if one person touches it, everyone’s local script will detect a hit and enable it.
dude thank you so much ive been trying to fine out how to fix this for so long and then im like, i should just ask dev form and now im glad that i did THANK YOU
I didn’t understand the wording in your post, but if you need it to only enable the Gui for the current player then either use a server-script for the least checks, or just verify that the player who touched the base part is the local player
as Gourmet did.
It would be better to add some sort of debounce unless the code below is to run too often.