This problem happens from time to time. But this time, when I looked in the developer's console in-game, it said character was a nil value. It works fine in studio however. Here's the script :
player = game.Players.LocalPlayer char = game.Players.LocalPlayer.Character hum = game.Players.LocalPlayer.Character.Humanoid mouse = game.Players.LocalPlayer:GetMouse() mouse.KeyDown:Connect(function(key) key = key:lower() if key == "e" then local fb = game:GetService("ServerStorage").Fireball:Clone() game:GetService("Chat"):Chat(char.Head, "Fireball!", "Red") fb.Parent = game.Workspace fb.Anchored = true if char.UpperTorso and char.LowerTorso then fb.CFrame = char.UpperTorso.CFrame + Vector3.new(0, 0, -2) else fb.CFrame = char.Torso.CFrame + Vector3.new(0, 0, -2) end end end)
First of all, you're using way too many unnecessary global variables. So, this RBX_Wiki article is something for you:
Change the first lines of your code to this:
-- LocalScript. local Plr = game:GetService("Players").LocalPlayer local Char = Plr.Character or Plr.CharacterAdded:wait()
And why are you trying to access the ServerStorage with a Local Script? You can't access it on the client!
You're welcome,
soved