Ok so i want this script to work only when the slapper tool is equipped so what am I doing wrong?
local Fireball = game.ServerStorage:WaitForChild("Fireball")
--Put tool they should have here
local tool = slapper
game.ReplicatedStorage.Fireball.OnServerEvent:Connect(function(player,cframe)
local character = player.Character
--Check if tool equipped, otherwise return/exit function
if character:FindFirstChild(tool.Name) == nil then return end
local newFireball = Fireball:Clone()
newFireball.CFrame = character.HumanoidRootPart.CFrame
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bodyVelocity.Velocity = (character.HumanoidRootPart.CFrame.lookVector*100)
bodyVelocity.Parent = newFireball
newFireball.Parent = workspace
local touchConn
touchConn = newFireball.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Name ~= player.Name then
local humanoid = hit:FindFirstAncestorWhichIsA("Model").Humanoid
humanoid:TakeDamage(25)
if touchConn ~= nil then touchConn:Disconnect() end
newFireball:Destroy()
end
end
end)
wait(2)
if touchConn ~= nil then touchConn:Disconnect() end
newFireball:Destroy()
end)