✓ Accepted answer
When you disable the script, you cannot enable it from the same script again, what you can do though to make it act like that is, use a debounce or a boolean to indicate weather you should change the speed or not like this:
local IsInvisible = false
script.Parent.Touched:Connect(function(p)
if IsInvisible == false then
if p.Parent:FindFirstChild("Humanoid") then
p.Parent.Humanoid.WalkSpeed = 25
script.Parent.Transparency = 1
IsInvisible = true
else
wait(5)
script.Parent.Transparency = 0
p.Parent.Humanoid.WalkSpeed = 16
IsInvisible = false
end
end
end)
You are also missing an "end" for the if statement.
You could also check if the transparency is 1 then run code otherwise, run other code... But I feel using debounce is more easier to use..
Oh and by the way, there is no point in saying script.Parent.script.Disabled = true......... script.Disabled = true is the same thing.
3 comments
don't you also think that disabling the script also means, you can't use the script for anything else, thus also not running lines 6 through 10
also, why bother with script.Parent.script, if you want to disable the script , just do script.Disabled = true
I think he might be referring to a different script inside the same block when he does that, but I don't know.