local p = game.Players.LocalPlayer.Character local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() Mouse.KeyDown:connect(function(Key) if Key == 'l' then if game.Players.LocalPlayer.MO.Value == "Fire" then local Part = Instance.new("Part") local Fire = Instance.new("Fire", Part) Fire.Size = 1 Fire.Heat = 1 Part.Shape = "Ball" Part.BrickColor = BrickColor.new("Really red") Part.Size = Vector3.new(1,1,1) Part.Parent = game.Workspace Part.Position = p.Torso.Position + p.Torso.CFrame.lookVector*5 Part.Velocity = p.Torso.CFrame.lookVector*5 * 40 + Vector3.new(0,40,0) Part.BottomSurface = "Smooth" Part.TopSurface = "Smooth" wait(5) Part:Destroy() Part.Touched:connect(function(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid ~= nil then humanoid.Health = 0 end end) end end end)
I find this issue odd, but whatever. The issue is that the script can't find 'p' in line 18. Yes, this script is inside of a LocalScript. This issue also doesn't happen in offline-testing, I only get this issue with server testing. Some help with this issue? The LocalScript is inside of the StarterGui.
Scripts run on the client before the character is created, so you can't directly get the character right away. Instead, do this:
local Player = game.Players.LocalPlayer local p = Player.CharacterAdded:wait()