I can't use LocalPlayer in a serverscript but I don't know how else to reference the player. I need help.
Here's the code:
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local RE = RS.SimpleFireBall
RE.onServerEvent:Connect(function(simpleFireBall)
local fireBall = Instance.new("Part", workspace)
fireBall.Anchored = false
fireBall.Size = Vector3.new(2,2,2)
fireBall.Shape = "Block"
local plr = game.Players.LocalPlayer
local char = plr.Character
local hum = char.Humanoid
fireBall.Orientation = char.LeftArm.Orientation
fireBall.CFrame = char.LeftArm.CFrame * CFrame.new(1,3,0)
end)
Thanks. Also here's the localscript:
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local RE = RS.SimpleFireBall
UIS.InputBegan:Connect(function(input, gameProcessedEvent)
if input.KeyCode == Enum.KeyCode.Z then
RE:FireServer()
end
end)

1 comment
Thanks!