This script is the child of a floating boulder that slowly disappears when you touch it, waits a few seconds, and then refreshes back to being visible
Here’s the issue:
The code works fine, but I want to make it so the boulder stops going transparent, then reappearing, going transparent, then reappearing even after the player moves off the boulder. When the player touches the boulder, the loop keeps going forever. Help?
Because when a player touches the part, it is not “the player” but all its parts, which will cause your code to be executed several times
Also if you want the Boulder to only activate if a player touches it you have to add a check for it, since with its current code it will activate when anything touches it, regardless if is a player or not.
For the transparency you should be use the TweenService with a debounce
local TS = game:GetService("TweenService")
local Debounce = false
boulder.Touched:Connect(function(TouchedPart)
if Debounce then
return
end
if TouchedPart.Parent:FindFirstChild("Humanoid") then
Debounce = true
TS:Create(boulder,Tween.new(Time),{Transparency = 1}):Play()
boulder.CanCollide = false
wait(Time)
boulder.CanCollide = true
boulder.Transparency = 0
Debounce = false
end
end)
It doesn’t fix your problem, but move your post to #help-and-feedback:scripting-support, or it might be removed, if you can’t report it and ask a moderator.
Yeah, but it still works just fine and accomplishes exactly what I need; that’s not the issue I’m trying to get addressed here. I do appreciate the advice though.