I am trying to make a tool that spawns a couple of fire balls above the player. When I tried this script out the fireballs spawned, but not above the player, where they are in ReplicatedStorage. Why? There is nothing in the explorer except these things: StarterPack > Tool > Script, and ReplicatedStorage > FireBalls. The Debounce (able) also doesnt work.
local able = true
script.Parent.Activated:Connect(function(player)
if able == true then
local PlusPosition = Vector3.new("0,50,0")
local fireballs = game:GetService("ReplicatedStorage").FireBalls:Clone()
fireballs.Parent = game.Workspace
fireballs.PrimaryPart.CFrame = player.Character.HumanoidRootPart.CFrame + PlusPosition
able = false
wait(5)
fireballs:Remove()
able = true
end
end)
Don’t put the Vector3 parameters in quotation marks. This is how you need to do it: local PlusPosition = Vector3.new(0,50,0)
When dealing with CFrames, you also have to use * instead of + to add onto it. So you should also turn the PlusPosition variable into a CFrame or put CFrame.new(PlusPosition)
And you should replace :Remove() with :Destroy() since :Remove() is deprecated.
Hmm thats strange it still doesnt seem to work! here is the code now that it’s updated:
local able = true
script.Parent.Activated:Connect(function(player)
if able == true then
local PlusPosition = Vector3.new(0,50,0)
local fireballs = game:GetService("ReplicatedStorage").FireBalls:Clone()
fireballs.Parent = game.Workspace
fireballs.PrimaryPart.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position + PlusPosition)
able = false
wait(5)
fireballs:Remove()
able = true
end
end)
Ah, just noticed player isn’t a parameter of the function Activated. Try to declare player like this inside of your activated function (and remove player from your function parameters):
local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)