Basically everything works fine except that I am trying to make it to where when the player creates the fireball it does not damage them, it damages the other player.
19:48:52.920 - IsDescendentOf is not a valid member of Workspace
That is the error I get and here is my script.
local player = game.Players.LocalPlayer mouse = player:GetMouse()
mouse.KeyDown:connect(function(plr)
if plr == "q" then
print(plr)
local bob = Instance.new("Part")
bob.Parent = game.Workspace
bob.Shape = "Ball"
bob.TopSurface = "Smooth"
bob.BottomSurface = "Smooth"
bob.Anchored = false
bob.Size = Vector3.new(5,5,5)
bob.CanCollide = false
bob.Transparency = .5
bob.BrickColor = BrickColor.new("Red")
bob.CFrame = player.Character.Torso.CFrame *CFrame.new(0,0,-20)
local thing = Instance.new("BodyVelocity",bob)
thing.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
thing.velocity = player.Character.Torso.CFrame.lookVector*80
local chat = game:GetService("Chat")
chat:Chat(player.Character.Head, "FireBall")
bob.Touched:connect(function(plr)
local hum = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")
if hum ~= nil and not bob.Parent:IsDescendentOf(script.Parent) then
hum:TakeDamage(20)
end
end)
local fire = Instance.new("Fire")
fire.Parent = bob
fire.Size = 10
local thing = game:GetService("Debris")
thing:AddItem(bob, 5)
thing:AddItem(chat, 5)
if player.leaderstats.Exp.Value >= 500 then
player.leaderstats.Exp.Value = player.leaderstats.Exp.Value - 500
else
local game = game:GetService("Chat")
game:Chat(player.Character.Head, "You dont have enough")
game.Players.LocalPlayer.Backpack.LocalScript.Disabled = true
end
end
end)

1 comment
just saying, keydown is deprecated. It still works, but not recommended for new work. The thing that replaces it is UserInputState (IsKeyDown)