So basically I have two scripts one is server side and the other one is local. One is in serverscriptservice. Other one is in StarterGUI.
So I am wondering why when I press the button to spawn blocks it decides to go ahead and say that localplayer is not a part of player.
---Server Code local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local createPartEvent = ReplicatedStorage:FindFirstChild("Spells")
local cooldown = "on"
local function Recieved(player)
if cooldown ~= "off" then
local torso = Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart")
local Part = Instance.new("Part")
Part.Parent = torso
Part.CFrame = torso.CFrame + torso.CFrame.LookVector * 10
cooldown = "off"
wait(10)
cooldown = "on"
wait(10)
Part:Destroy()
end
end
createPartEvent.OnServerEvent:Connect(Recieved)
--local script
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Spells = ReplicatedStorage:WaitForChild("Spells")
local UIS = game:GetService("UserInputService")
local cooldown = "on"
UIS.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard then -- Checks if the input was related to a keyboard
if input.KeyCode == Enum.KeyCode.Q then
if Players.LocalPlayer.Character then
Spells:FireServer()
end
end
end
end)

2 comments
Sorry for the script being hard to copy
LocalPlayer can't be replicated over the server/client boundary. It's strictly client-only.