I'm making a spells script and in play solo of course the player loads before anything else unlike on a actual roblox server the scripts load before the character so when I go to play online my script doesn't work
I tried using player.CharacterAdded:wait() but It doesn't work i'm not even sure if its supposed to be used for this issue ]
heres my script :
local player = game.Players.LocalPlayer
local Player = game.Players.LocalPlayer
local Mouse = player:GetMouse()
player.CharacterAdded:wait()
RightShoulder = Player.Character.Torso["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
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)

5 comments
Uh, why you defines 2 LocalPlayers in the script...?
game:IsLoaded
im a noob scripter but i think you could try game.Players.WaitForChild("Player")
bruh this is from 5 years ago why would he reply?
lol