so am remastering that cube script and trying to make aparticle emit but gives me a error?
-- this is a script in serverscriptservice
local Cubes = game.Workspace.CubesFolder
local DB = false
for _, Cube in pairs(Cubes:GetChildren()) do
Cube.Touched:Connect(function(hit)
local char = hit.Parent
local hum = char:FindFirstChild("Humanoid")
local hrp = char:FindFirstChild("HumanoidRootPart")
if hum and hum.Parent == char and not DB then
local particle = hrp:FindFirstChild("HitParticle")
DB = true
local player = game.Players:GetPlayerFromCharacter(char)
player.leaderstats.Cubes.Value += 1
particle:Emit(1)
Cube:Destroy()
end
end)
end
If this is for 1 individual Cube, thatâs fine but if youâre using multiple why not encase the DB in with the loop?
Your particle variable could be defined as nil if there isnât even a HitParticle in there to begin with
It could be possible that it is calling Emit(), but youâre only just emitting 1 particle & thatâs it
Also check for the hrp as well, you never know what may happen
local Cubes = workspace.CubesFolder
local DB = false
for _, Cube in pairs(Cubes:GetChildren()) do
Cube.Touched:Connect(function(Hit)
local Hum = Hit.Parent:FindFirstChild("Humanoid")
local HRP = Hit.Parent:FindFirstChild("HumanoidRootPart")
local Plr = game.Players:GetPlayerFromCharacter(Hit.Parent)
if not DB and Hum and HRP and HRP:FindFirstChild("HitParticle") and Plr then
DB = true
Plr.leaderstats.Cubes.Value += 1
HRP.HitParticle:Emit(1)
--wait(Duration)
--DB = false - Not sure if you need this or not
end
end)
end
This is the problem with your code. The hrp doesnât have a child named âHitParticleâ. Double check the name, that youâre looking for âHitParticleâ in hrp, and that you create the particle emitter.