It dose it for everyone even tho im using a local script

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?

script.Parent.Enabled = false

local thing = game.Workspace.Store.Touch

thing.Touched:Connect(function()
script.Parent.Enabled = true
end)

4 Likes

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.

Where is the location of the script if its on workspace try to put it on ReplicatedFirst Service

first off when you said how didi i test it, yah i went in the game and got my friend who we worked on this game together and we found that bug

second off, ill try what you said thanks

yah non of it works
all your ideas all just basically do the same thing

sorry but, how do i do that?
please tell me so i can do it

is that on roblox studio or were is that? sorry to be a pain

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)
6 Likes

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.

1 Like

so how do i fix that, i thoguht that may be the problem but i dont know how to fix that

Do what galaxy gourmet said.

1 Like

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.