Basicly I am trying to clone random ParticlesEmitters from ReplicatedStorage into the “spray” I tried to make that but I am getting some erros with that. (when the spray(part) touch something one random ParticlesEmitter will be cloned into the spray.)
You’re trying to get the length of a number here. Instead search through the children for a random index.
Simple fix: local colorRandomClone = colorsChildrens[math.random(1, #colorsChildrens)]
The colorRandomClone variable is wrong. The # symbol is used to get the length of a table or string, but you’re using it on a number, which is incorrect. You also aren’t indexing the ‘childrens’ table to find this random spray.
Your fixed variable should be: local colorRandomClone = colorChildrens[math.random(1, #colorsChildrens)]
I have the damage script and this script inside the ServerScriptService
ServerScriptService:
local debounce = false
local spray = script.Parent
local function player_check(otherPart)
if not otherPart.Parent:FindFirstChild("Humanoid") then return end
local humanoid = otherPart.Parent.Humanoid
local character = humanoid.Parent
local humanoidRoot = character.HumanoidRootPart
if humanoid.Parent.Name ~= spray.Attacker.Value then
if otherPart.Name == "Head" then
humanoid:TakeDamage(35)
else
humanoid:TakeDamage(20)
end
end
debounce = false
end
spray.Touched:Connect(player_check)
game.Debris:AddItem(spray, 3)
I used the value with player name for not damage the tool user
local function player_check(otherPart)
if not otherPart.Parent:FindFirstChild("Humanoid") then return end
local Attacker = spray:FindFirstChild("Attacker")
if Attacker then
local humanoid = otherPart.Parent.Humanoid
local character = humanoid.Parent
local humanoidRoot = character.HumanoidRootPart
if humanoid.Parent.Name ~= Attacker.Value then
if otherPart.Name == "Head" then
humanoid:TakeDamage(35)
else
humanoid:TakeDamage(20)
end
end
debounce = false
end
end
Not it’s not. It does exist. Indexing like so: A.B —> script thinks that B is a children of A
Attacker is a string name. Indexing string requires using the square brackets or other means such as FindFirstChild, WaitForChild, etc.