Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to I make a script that when the player touches a part it disappears?

Lets say a player touches a part, the parts transparency will go to 0 until it changes back within the time given. But when the touch it it doesn't disappear for anyone but the player who touched it.

3 comments

0

Just add a script to the client that changes the transparency of the part. Make sure that when you are calling for the script that changes transparency, you are not firing the client. It will make the client have server side permissions. This uses FE if you are unfamiliar with why this should work. 

0

could you put the script in a link below

0

I sent a response

3 answers

local part = script.Parent
local function onTouched(part)
part.Transparency = 1
wait(10) 
part.Transparency = 0 
end
part.Touched:Connect(onTouched)

4 comments

0

But I only want the player who touched it to see it disappear, for other players it should look like nothing has changed.

0

Make it a local script

0

It didn't work as a local script

0

????

Make a LocalScript in StarterPack and do the following:

local Part = workspace.Part -- Change to your part name
Part.Touched:Connect(function(hit)
    If hit.Parent:FindFirstChildWhichIsA("Humanoid") then
           Part.Transparency = 1
            wait(2)
          Part.Transparency = 0
      end)
end)

If it doesn't work, comment the Error in the output. Hope this helps! Bye!

Question: Let's say a player touches a brick, the part's transparency will go to 0 until it changes back within the time given. But when the touch it doesn't disappear for anyone but the player who touched it.

Answer: Ok. Here's the script, but wait! Do that as a LocalScript. Don't do anything in your's workspace:

local cc = workspace.CurrentCamera
local part = game.Instance.new("Part", cc)
debounce = false

part.Position = Vector3.new(0,0,0) -- set the part that where it could spawn on
part.Anchor = true

function OnTouched()
	debounce = true
	part.Transparency = 1 
	wait(10) -- change the time that you wanted to make it cooldowns for changing back to the default transparency
	part.Transparency = 0
	debounce = false
end)

If this doesn't work, comment below! I'll try my best to fix this :)

Also note again: DON'T DO ANYTHING IN WORKSPACE AND MAKE THE SCRIPT A LOCAL SCRIPT.

This discussion is preserved as it was. New answers, comments, and votes are closed.