I'm making a magic fighting game but my spells will load before the character does in online mode and then not work... and I've gotten help but it didn't help the issue
heres the script :
local Player = game:GetService'Players'.LocalPlayer
local character = Player:WaitForChild("Character")
local Mouse = Player:GetMouse()
local head = character:WaitForChild'Head'
local torso = character:WaitForChild'Torso'
local rightShoulder = Torso:WaitForChild'Right Shoulder'
Run = game:getService("RunService")
Mouse.KeyDown:connect(function(key)
if script.Wait.Value == false then
if key == "f" then
script.Wait.Value = true
for i = 1, 2 do
for i = 1, 12 do
RightShoulder.C0 = RightShoulder.C0 *CFrame.Angles(0, 0, 0.16)
RightShoulder.C0 = RightShoulder.C0 *CFrame.Angles(0, 0, 0)
Run.Stepped:wait(0.01)
end
for i = 1, 12 do
RightShoulder.C0 = RightShoulder.C0 *CFrame.Angles(0, 0, 0)
RightShoulder.C0 = RightShoulder.C0 *CFrame.Angles(0, 0, -0.16)
Run.Stepped:wait(0.005)
end
end
for i = 1, 12 do
RightShoulder.C0 = RightShoulder.C0 *CFrame.Angles(0, 0, 0)
RightShoulder.C0 = RightShoulder.C0 *CFrame.Angles(0, 0, 0)
Run.Stepped:wait(0.005)
end
game:getService("Chat"):Chat(Player.Character.Head, "FireBall!")
local p = Instance.new("Part", Workspace)
p.Color = Color3.new(0, 0, 0)
p.Transparency = 0.5
p.Size = Vector3.new(3, 3, 3)
p.TopSurface = "Smooth"
p.BottomSurface = "Smooth"
p.CanCollide = false
p.Shape = "Ball"
s = script.FD:Clone()
s.Parent = p
s.Disabled = false
p.CFrame = Player.Character.Torso.CFrame*CFrame.new(0, 0, -12)
y = Instance.new("BodyVelocity", p)
y.maxForce = Vector3.new(math.huge, math.huge, math.huge)
y.velocity = Player.Character.Torso.CFrame.lookVector*80
local f = Instance.new("Fire", p)
wait(6)
game.Debris:addItem(p, 1)
script.Wait.Value = false
else print'waiting'
end
end
end)

2 comments
this works until the character dies then the entire thing errors out
No it does not. This PREVENTS the script from breaking if the character is not loaded yet.