Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

When I click, the fireball won't shoot. Why? Please Help.

Asked by
phxtn 154
7 years ago
Edited 7 years ago

Help This script doesn't work. This is in a script. Not a local one.

local Tool = script.Parent
play = Tool.Parent.Parent
mouse =play:GetMouse()
char = play.Character
hum = char.Humanoid
root = char.HumanoidRootPart

local en = true

Tool.RemoteEvent.OnServerEvent:connect(function(play.mousehit)
 local a = hum:LoadAnimation(Tool.Throw)
 a:Play()
 root.CFrame = CFrame.new(root.Position.root.Position + Vector3.new(mousehit.lookVector.x,0,mousehit.lookVector.z)
 wait(0.7)
 local fireball = ToolHandle:clone()
 fireball.CFrame = Tool.Handle.CFrame
 local bv = Instance.new("bodyVelocity")
 bv.MaxForce = Vector3.new(1e8,1e8,1e8)
 bv.Velocity = mouse.hit.lookVector - 50
 bv.Parent = fireball
 fireball.Parent = game.Workspace
 game.Debris:AddItem(fireball,4)
 local ten = true
 fireball.Touched:connect(function(hit)
  if not ten then return end
  ten = false
  local ehum = hit.Parent:findFirstChild("Humanoid") or hit.Parent.Parent:findFirstChild("Humanoid")
  if ehum and ehum -= hum then
   ehum:TakeDamage(10)
  elseif hit.Anchored == true and hit.CanCollide == true then 
   for i=1,10n do
    local part = fireball:clone()
    part.Size = Vector3.new(1,1,1)
    part.CFrame = fireball.CFrame
    part.Bodyvelocity.MaxForce = Vector3.new(1e8,0,1e8)
    part.ParticleEmitter.LockedToPart = false
    part.BodyVelocity.Velocity = Vector3.new(math.random(-30,30),math.random(-30,30),math.random(-30,30)
    part.Parent = game.Workspace
    game.Debris.AddItem(part,1)
   end
  end

  wait()
  ten = true
 end)

end)
0
Photon, I think the 2nd line until the 6th line needs a local at the front. But I'm not sure. mingss1000 11 — 7y
0
^ wrong, but making it local makes it less laggy; also you can't get the player's mouse from a server-script thehybrid576 294 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Does this work, I don't know if it will

local Tool = script.Parent
play = Tool.Parent.Parent
mouse = play:GetMouse()
char = play.Character
hum = char.Humanoid
root = char.HumanoidRootPart

local en = true

Tool.RemoteEvent.OnServerEvent:connect(function(play)mousehit
 local a = hum:LoadAnimation(Tool.Throw)
 a:Play()
 root.CFrame = CFrame.new(root.Position.root.Position + Vector3.new(mousehit.lookVector.x,0,mousehit.lookVector.z)
 wait(0.7)
 local fireball = ToolHandle:clone()
 fireball.CFrame = Tool.Handle.CFrame
 local bv = Instance.new("bodyVelocity")
 bv.MaxForce = Vector3.new(1e8,1e8,1e8)
 bv.Velocity = mouse.hit.lookVector - 50
 bv.Parent = fireball
 fireball.Parent = game.Workspace
 game.Debris:AddItem(fireball,4)
 local ten = true
 fireball.Touched:connect(function(hit)
  if not ten then return end
  ten = false
  local ehum = hit.Parent:findFirstChild("Humanoid") or hit.Parent.Parent:findFirstChild("Humanoid")
  if ehum and ehum -= hum then
   ehum:TakeDamage(10)
  elseif hit.Anchored == true and hit.CanCollide == true then 
   for i=1,10n do
    local part = fireball:clone()
    part.Size = Vector3.new(1,1,1)
    part.CFrame = fireball.CFrame
    part.Bodyvelocity.MaxForce = Vector3.new(1e8,0,1e8)
    part.ParticleEmitter.LockedToPart = false
    part.BodyVelocity.Velocity = Vector3.new(math.random(-30,30),math.random(-30,30),math.random(-30,30)
    part.Parent = game.Workspace
    game.Debris.AddItem(part,1)
   end
  end

  wait()
  ten = true
 end)

end)



Ad

Answer this question