I’m not sure why but everytime I try to emit through the script the particles just don’t end up working and I’ve been stuck on this for a while now.
local rs = game:GetService("ReplicatedStorage")
local contentProvider = game:GetService("ContentProvider")
local debris = game:GetService("Debris")
local tpParts = workspace:WaitForChild("teleportParts")
local teleportOne = script.Parent
local teleportTwo = tpParts:WaitForChild("p2")
local debounce = false
local cd = 2.5
local teleportSFX = rs:WaitForChild("teleportSFX"):Clone()
contentProvider:PreloadAsync({teleportSFX})
local function playSound()
teleportSFX.Parent = workspace.Ignore
teleportSFX:Play()
end
teleportOne.Touched:Connect(function(hit)
if debounce == true then print("on cd") return end
debounce = true
local humRP = hit.Parent:FindFirstChild("HumanoidRootPart")
if not humRP then debounce = false return end
local function emitBurst()
local sparkleFX = rs:WaitForChild("sparkleFX"):Clone()
sparkleFX.Parent = humRP
sparkleFX.Position = humRP.Position + Vector3.new(0,-.5)
sparkleFX.Attachment.Burst:Emit(8)
sparkleFX.Attachment.Sparkles:Emit(18)
debris:AddItem(sparkleFX, .5)
end
humRP.CFrame = teleportTwo.CFrame + Vector3.new(0,5,0)
playSound()
emitBurst()
task.wait(cd)
debounce = false
end)
teleportTwo.Touched:Connect(function(hit)
if debounce == true then print("on cd") return end
debounce = true
local humRP = hit.Parent:FindFirstChild("HumanoidRootPart")
if not humRP then debounce = false return end
local function emitBurst()
local sparkleFX = rs:WaitForChild("sparkleFX"):Clone()
sparkleFX.Parent = humRP
sparkleFX.Position = humRP.Position + Vector3.new(0,-.5)
sparkleFX.Attachment.Burst:Emit(8)
sparkleFX.Attachment.Sparkles:Emit(18)
debris:AddItem(sparkleFX, .5)
end
humRP.CFrame = teleportOne.CFrame + Vector3.new(0,5,0)
playSound()
emitBurst()
task.wait(cd)
debounce = false
end)
Do they emit when you test and set the emitter to enabled?
Is everything else working properly? (the teleport, sound, etc.)
Put prints in your code for troubleshooting that include the variables for your checks so you can see why they are or aren’t working.
For example:
teleportOne.Touched:Connect(function(hit)
print("on cd check, debounce = ", debounce) -- print("on cd") in the next
-- check will only confirm it's true. If you print the variable
-- you'll see if it's nil, or something else unexpected
if debounce == true then --[[print("on cd")]] return end
debounce = true
local humRP = hit.Parent:FindFirstChild("HumanoidRootPart")
print(humRP.Name) -- lets you know if the next section of code is checking something unexpected
if not humRP then debounce = false return end
-- rest of code
local rs = game:GetService("ReplicatedStorage")
local contentProvider = game:GetService("ContentProvider")
local debris = game:GetService("Debris")
local tpParts = workspace:WaitForChild("teleportParts")
local teleportOne = script.Parent
local teleportTwo = tpParts:WaitForChild("p2")
local debounce = false
local cd = 2.5
local teleportSFX = rs:WaitForChild("teleportSFX"):Clone()
contentProvider:PreloadAsync({teleportSFX})
local function playSound()
teleportSFX.Parent = workspace.Ignore
teleportSFX:Play()
end
local function emitBurst(humRP)
local sparkleFX = rs:WaitForChild("sparkleFX"):Clone()
sparkleFX.Parent = humRP
sparkleFX.Position = humRP.Position + Vector3.new(0,-.5)
sparkleFX.Attachment.Burst:Emit(8)
sparkleFX.Attachment.Sparkles:Emit(18)
debris:AddItem(sparkleFX, 10)
end
teleportOne.Touched:Connect(function(hit)
if debounce == true then print("on cd") return end
debounce = true
print("Part collided with something")
local humRP = hit.Parent:FindFirstChild("HumanoidRootPart")
if not humRP then debounce = false return end
print("It was a humanoid")
humRP.CFrame = teleportTwo.CFrame + Vector3.new(0,5,0)
print("Playing sound...")
playSound()
print("Emitting...")
emitBurst(humRP)
task.wait(cd)
debounce = false
end)
teleportTwo.Touched:Connect(function(hit)
if debounce == true then print("on cd") return end
debounce = true
print("Part collided with something")
local humRP = hit.Parent:FindFirstChild("HumanoidRootPart")
if not humRP then debounce = false return end
print("It was a humanoid")
humRP.CFrame = teleportOne.CFrame + Vector3.new(0,5,0)
print("Playing sound...")
playSound()
print("Emitting...")
emitBurst(humRP)
task.wait(cd)
debounce = false
end)