How do I make this disappearing part script local?

I finished making this script for my obby-style game that makes a part fade away after it has been touched (and regen a few seconds later) for an additional challenge. Later on, I realized that players could essentially make sections of levels unbeatable by repeatedly activating the disappearing script. Making it local would be the perfect fix but I’m not sure how I would go about doing it. Any help would be greatly appreciated!

Video demonstration: Screen Recording 2022-01-03 at 6.45.38 PM

if isTouched == false then
		gravel.Transparency = 0.1
		texture.Transparency = 0.1
		isTouched = true
		wait(0.2)
		gravel.Transparency = 0.2
		texture.Transparency = 0.2
		wait(0.2)
		gravel.Transparency = 0.3
		texture.Transparency = 0.3
		wait(0.2)
		gravel.Transparency = 0.4
		texture.Transparency = 0.4
		wait(0.2)
		gravel.Transparency = 0.5
		texture.Transparency = 0.5
		wait(0.2)
		gravel.Transparency = 0.6
		texture.Transparency = 0.6
		wait(0.2)
		gravel.Transparency = 0.7
		texture.Transparency = 0.7
		wait(0.2)
		gravel.Transparency = 0.8
		texture.Transparency = 0.8
		wait(0.2)
		gravel.Transparency = 0.9
		texture.Transparency = 0.9
		wait(0.2)
		gravel.Transparency = 1
		texture.Transparency = 1
		gravel.CanCollide = false
		wait(5)
		gravel.Transparency = 0
		texture.Transparency = 0
		gravel.CanCollide = true
		isTouched = false
	end
end

gravel.Touched:connect(PlayerTouched)
1 Like

A few notes, one: Please use TweenService as it was meant for this kind of stuff and smoothly transitions values from their start point to their end point. two: You can detect the touched event on the client and handle it from there. If you want it to be invisible for all players after the touch, you can use a RemoteEvent to fire to the server and then use :FireAllClients().

Dude, use TweenService

Now for the part to disappear for just the player. Strangely a local script in StarterGui or other player related thing, will work.

1 Like