(My filtering enabled is off)
local tool = script.Parent
local player = tool.Parent.Parent
local mouse = player:GetMouse()
local root = player.Character.HumanoidRootPart
tool.RemoteEvent.OnServerEvent:connect(function(player,mousehit)
if player.Character:FindFirstChild("multiattackprevention") then return end
local multiattackprevention = Instance.new("StringValue")
multiattackprevention.Parent = player.Character
multiattackprevention.Name = ("multiattackprevention")
local hitcooldown = false
local animation = player.Character.Humanoid:LoadAnimation(tool.SuperJump)
animation:Play()
local bv = Instance.new("BodyVelocity")
bv.Parent = player.Character.Torso
bv.Velocity = Vector3.new(0,250,0)
wait(1)
bv.Velocity = Vector3.new(0,0,0)
wait(0.01)
bv:Destroy()
wait(0.4)
player.Character.Torso.Anchored = true
root.CFrame = mouse.Origin
local animation2 = player.Character.Humanoid:LoadAnimation(tool.Cast)
animation2:Play()
wait(0.5)
local magmadrag = Instance.new("Part")
magmadrag.Transparency = 0.5
magmadrag.Parent = game.Workspace
magmadrag.Position = player.Character:FindFirstChild("Right Arm").Position
magmadrag.CanCollide = false
magmadrag.TopSurface = ("Smooth")
magmadrag.BottomSurface = ("Smooth")
magmadrag.BrickColor = BrickColor.new("Bright red")
magmadrag.Material = ("Ice")
magmadrag.Size = Vector3.new(30,30,30)
local bv = Instance.new("BodyVelocity")
bv.Parent = magmadrag
bv.MaxForce = Vector3.new(1e8,1e8,1e8)
bv.Velocity = mouse.Origin.lookVector * 150
local sound = Instance.new("Sound")
wait(0.5)
magmadrag.CanCollide = true
multiattackprevention:Destroy()
wait(0.5)
player.Character.Torso.Anchored = false
magmadrag.Touched:connect(function(hit)
magmadrag.Anchored = true
bv.Velocity = mousehit.lookVector * 0
if hitcooldown == true then return end
local enemy = hit.Parent:FindFirstChild("Humanoid")
if enemy == player.Character.Humanoid then return end
if enemy then
enemy.Health = enemy.Health - 400
hitcooldown = true
wait(3)
magmadrag:Destroy()
else wait(3)
magmadrag:Destroy()
wait(0.5)
end
end)
wait(10)
magmadrag:Destroy()
end)
So this script runs perfectly fine in studio test mode, however in play mode, the player jumps up but then simply stays anchored in the air and doesn't fire the projectile.
In play mode server log I get the error:
Players.Citranix.Backpack.Magma Dragon.Script:24: attempt to index upvalue 'mouse' (a nil value)
I do not want the projectile to fire towards the original mouse hit which fired this function, I want it to delay and then shoot towards where the players mouse currently is.
