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

How do I make a part when touched will disappear only on your screen ?

local db = true
script.Parent.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") ~= nil then
		if db == true then
			db = false
			script.Parent.Transparency = 1
			local player = game.Players:GetPlayerFromCharacter(hit.Parent)
			player.leaderstats.Bricks.Value = player.leaderstats.Bricks.Value + 1
			script.Sound:Play()
			wait(1)
			script.Parent:Remove()
		end
	end	
end)

So this is the script I made but I dont know how to make it only disappear on your screen but everybody can go get it

5 comments

1

Try putting that code in a LOCALSCRIPT. I haven't scripted in a while and know nothing about FE, but give that a try.

0

edit:- codeblock

0

I tryed that but doesnt work

0

Did you want it to disappear only for you? Theres nothing wrong with your code

0

I want to make it disappear only for me I put it in a script but it shows up for everyone when I put it in local script it wont do anything

2 answers

Use Remote Events to do this. You make a client remoteevent and connect your script to that user. Probably using this script below

Localscript in StarterGui

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(part, method)
	if part and method == "invis" then
		part.Transparency = 1
		part.CanCollide = false
	elseif part and method == "show" then
		part.Transparency = 0
		part.CanCollide = true
	end
end)

Server Script in Workspace or ServerScriptService

script.Parent.Touched:Connect(function(plr)
	if plr and plr.Parent:FindFirstChild("Humanoid') then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		
		game.ReplicatedStorage.RemoteEvent:FireClient(player, script.Parent, "invis")
	end
end)

make sure that the local script is in game.Players.StarterPack.StarterScripts or something like that because that way, it will only apply to the player

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