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

How to make a model not transparent when a part is hit?

I tried using a local script on a part and it doesn't work. This script was supposed to make a person hallucinate and only that person who was affected by it can see the entity.

local plr = game.Players.LocalPlayer
script.Parent.Touched:Connect(function()
	if plr and debounce == false then
		debounce = true
		for i,v in pairs(workspace.Dummy:GetChildren())
			if v.ClassName == "Part" then
				v.Transparency = 0
			end
		end
	end
end)

It never really show any errors. I'm not sure what's wrong with it.

4 comments

0

you can't use a local script with the touched function.

0

So do I use a fire client event?

0

no use a script

0

game.Players.PlayerAdded:Connect(function(plr) will substitute for local player in a script

1 answer

Put this in a SERVER SCRIPT(just "Script"), NOT a LOCAL SCRIPT!

game.Players.PlayerAdded:Connect(function()
plr = true
end)
script.Parent.Touched:Connect(function()
if plr and debounce == false then
debounce = true
for i,v in pairs(workspace.Dummy:GetChildren())
   if v.ClassName == "Part" then
v.Transparency = 0
end
end
end
end)

Sorry for the bad formatting, im on mobile and i needed to re-write the script.

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