I had the bright idea to make the clones a kill brick, so you can use the friend as a weapon. When it spawns the clones, as it spawns them the exact same place as the real tool, it kills the player. I need to know how to make it so that it spawns the clones 5 studs away from the front of the player.
Current code:
local friend = script.Parent
local ball = friend.Handle
local db = false
if db == false then
db = true
script.Parent.Activated:Connect(function()
local ballClone = ball:Clone()
ballClone.Name = "Friend's Friend"
ballClone.Parent = workspace
ballClone.CanCollide = true
ballClone.Position = ball.Position
ballClone.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChildOfClass("Humanoid")
if hum then
hum:TakeDamage(29453475935739457897057)
end
end)
wait(10)
ballClone:Destroy()
end)
wait(1)
db = false
else
db = false
script.Parent.Activated:Connect(function()
local ballClone = ball:Clone()
ballClone.Name = "Friend's Friend"
ballClone.Parent = workspace
ballClone.CanCollide = true
ballClone.Position = ball.Position
ballClone.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChildOfClass("Humanoid")
if hum then
hum:TakeDamage(29453475935739457897057)
end
end)
wait(10)
ballClone:Destroy()
end)
wait(1)
db = true
end
It wouldnât matter, try the script without it and you will get the exact same result.
Debounces are used when you have a loop and you dont want to run the same script twice or let it time to complete before running it again if its an event.
If the second option is what youre aiming for then youre doing it wrong
Right now your debounce and script are built in a way that it doesnt do anything;
You are setting the debounce to false
You check if its false and then set it to true
You connect the activated event
You set the debounce to false
and the debounce never runs again
If you want to wait for the function to finish before you run it again you need to put the debounce inside of the function.
When I was still having trouble with the previous post, I had the function in a while true do loop. I then added the debounce because someone told me to, and then I figured out the problem (I think): adding an if statement. Absent mindedly, I kept and âfixedâ the script so that it would still have the debounce without needing it in the if statement.
Attempt to index ânilâ with character. The classic.
Full error:
Players.DementedDivinity.Backpack.friend.Script:10: attempt to index nil with âCharacterâ - Server - Script:10