I have this particle effect playing when a player enters the water, when reset however, the particle wont play again.
local water = game.Workspace:WaitForChild("Water")
local bubbles = game.ReplicatedStorage.Particles.Bubbles
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
water.Touched:Connect(function(hit)
if hit and hit.Parent:FindFirstChild("Humanoid") then
bubbles.Parent = char.Torso
bubbles.Enabled = true
end
end)
water.TouchEnded:Connect(function()
bubbles.Enabled = false
end)
I couldnt find an answer to a situation like this, where you need the particle to play again after death BUT only when player is in the part.
Note:
-Function done by player touching PART (which i put around water)
-Done in local script in starterPlayerScripts
-Tried clone function on lines (3 after bubbles) and (10 after bubbles)
because youre getting the torso from the char variable, when the player resets the char variable will be set to nil because the player will get a new character,
local water = game.Workspace:WaitForChild("Water")
local bubbles = game.ReplicatedStorage.Particles.Bubbles
local NewBubbles = nil
water.Touched:Connect(function(hit)
if hit and hit.Parent:FindFirstChild("Humanoid") then
NewBubbles = bubbles:Clone()
NewBubbles.Parent = hit.Parent:FindFirstChild("Torso")
NewBubbles.Enabled = true
end
end)
water.TouchEnded:Connect(function()
if (NewBubbles == nil) then return end
NewBubbles.Enabled = false
end)
Found the solution!
So i re did the clone function on line 3 because that one did cause it to dup alot of time and i did Parent:FindFirstChild(“Torso”) on line 10 instead thanks to CZXPEK
local water = game.Workspace:WaitForChild("Water")
local bubbles = game.ReplicatedStorage.Particles.Bubbles:Clone()
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
water.Touched:Connect(function(hit)
if hit and hit.Parent:FindFirstChild("Humanoid") then
bubbles.Parent = hit.Parent:FindFirstChild("Torso")
bubbles.Enabled = true
end
end)
water.TouchEnded:Connect(function()
bubbles.Enabled = false
end)
local water = game.Workspace:WaitForChild("Water")
local bubbles = game.ReplicatedStorage.Particles.Bubbles:Clone()
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
water.Touched:Connect(function(hit)
if hit and hit.Parent:FindFirstChild("Humanoid") then
bubbles.Parent = hit.Parent:FindFirstChild("Torso")
bubbles.Enabled = true
end
end)
water.TouchEnded:Connect(function()
bubbles.Enabled = false
end)