I am trying to make a GUI pop up after touching a part, the part will then be removed after being touched. The problem is that the part removes for all players after being touched by only one. How would I make this part only remove for the person touching it?
COMMUNITY QUESTION
How to make a part dissapear for ONLY the player touching it?
1 answer
Use a LocalScript, that way it only works for one client.
local Part = nil -- change to part location
local Players = game:GetService('Players')
local UI = nil -- change this to UI location
function onTouched(Hit)
local Player = Players:GetPlayerFromCharacter(Hit.Parent)
if Player then
local newUI = UI:Clone()
newUI.Parent = Player.PlayerGui
Part:Destroy()
end
end)
part.Touched:Connect(onTouched)
2 comments
0
This did not remove the part, I put the local script inside of the part. Should I put it somewhere else?
0
You should put in StarterGui, ReplicatedFirst or [StarterCharacter/Player]Scripts.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Copy the code into a local script, and make it work on the local side