So let’s say a player steps on a part, it will disappear, but for other players it should look like no change was made until they step on the part?
Code in a LocalScript
runs purely on the client, which we can take advantage of here to do something that won't affect every other player's script.
Inside a Part
is an Event
called Touched
, which when receives the signal that something has touched it will invoke any functions connected to it through the Connect
method.
The Connect
method takes a function, which will be invoked with whatever hit the part.
local Part = workspace:WaitForChild("PartNameHere") Part.Touched:Connect(function(Hit) -- This is the hit argument that will be passed to our function. if Hit.Parent:FindFirstChild("Humanoid") then Part.Visible = false end end)
-- Local script & make sure filtering enabled is on. local part = script.Parent --Part location here. eg. workspace.Part part.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then -- Checks if hit is a player. part:Destroy() -- You can use part.Transparency, but since you said 'disappear', I'm assuming you want to remove it. end end)
The only problem with the other two answers ^^ is the script will run when any player touches the part, not just when that player touches it. Try using this script:
local Players = game:GetService("Players") player = Players.LocalPlayer -- This is the player this script currently applies to local Part = workspace:WaitForChild("Part") -- Reference the part you want to disappear here Part.Touched:Connect(function(Hit) if Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent.Name = player.Name then -- This will check that 1. It is a player's character that hit the part 2. It is the user's character so the part will only disappear for them if they're the one to touch it Part.Visible = false -- Makes the part invisible end end)
I hope this helps!
Closed as Not Constructive by hiimgoodpack and WideSteal321
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?