So, I made a script inside a part that needs to give a player a speed boost, and adds some cool trail to both of the player’s feet. I use Tweening to make the part transparent after it has been triggered, but my script stops working after the “test” print, and I can’t figure out why.
Here’s the script:
script.Parent.Touched:Connect(function(hit)
if game.Players:FindFirstChild(hit.Parent.Name) then
local Info = TweenInfo.new(1)
local Tween = game:GetService("TweenService"):Create(script.Parent,Info,{Transparency=1})
local debounce = false
local humanoid = hit.Parent:WaitForChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local Boosted = player:WaitForChild("Boosted")
if humanoid ~= nil and debounce == false and Boosted.Value == false then
debounce = true
script.Parent.BrickColor = BrickColor.new("Toothpaste")
script.Parent.Material = "Neon"
local att1 = Instance.new("Attachment", hit.Parent.LeftFoot)
att1.Name = "trailatt"
local att2 = Instance.new("Attachment", hit.Parent.RightUpperLeg)
att2.Name = "trailatt"
local trail1 = game.ReplicatedStorage.FlashTrail:Clone()
trail1.Parent = hit.Parent.LeftFoot
trail1.Attachment0 = att1
trail1.Attachment1 = att2
local att3 = Instance.new("Attachment", hit.Parent.RightFoot)
att1.Name = "trailatt"
local att4 = Instance.new("Attachment", hit.Parent.RightUpperLeg)
att2.Name = "trailatt"
local trail2 = game.ReplicatedStorage.FlashTrail:Clone()
trail2.Parent = hit.Parent.RightFoot
trail2.Attachment0 = att3
trail2.Attachment1 = att4
humanoid.WalkSpeed = 40
Boosted.Value = true
script.Parent.CanCollide = false
Tween:Play()
print("tween")
Tween.Completed:Wait()
print("done")
wait(1)
print("test")
wait(1)
humanoid.WalkSpeed = 16
trail1:Destroy()
trail2:Destroy()
end
end
end)