Problem with remoteevent/function script

So I’m making a remote event and function script in serverscriptservice in a server script.
It gives the player the tools after they decided what they wanted and clicked play.
I tried a lot of things but they didn’t work. (note: the firing the remote event works since it shares the remote with another script) I think the problem is the localplayer part since it can only be read (which I don’t know what it mean) Can somebody tell me whats wrong with the script?

local remote = game:GetService("ReplicatedStorage").NormalR
local player = game.Players.LocalPlayer
local weap = player.PlayerGui.Weaponry.GunsList
local main = weap.MainValue
local sec = weap.SecondaryValue
local knife = weap.KnifeValue
local boo = game.Lighting.Guns:FindFirstChild("" ..main)
local boop = game.Lighting.Guns:FindFirstChild("" ..sec)


remote.OnServerEvent:Connect(function()


	
	local c = boo:clone()
	c.Parent = player.Backpack
	local d = boo:clone()
	d.Parent = player.StarterGear

	local e = boop:clone()
	e.Parent = player.Backpack
	local f= boop:clone()
	f.Parent = player.StarterGear

	print("gave tools")
end)

You can’t do game.Players.LocalPlayer in a server script, the player is default first argument for remote event too. So put the player parameter in the event function and make all your variables using the player in the function too

1 Like

figured. How do I get a local player though? Oh wait I didn;t read all of it

Like I said do this:

local remote = game:GetService("ReplicatedStorage").NormalR

remote.OnServerEvent:Connect(function(player)
    local weap = player.PlayerGui.Weaponry.GunsList
    local main = weap.MainValue
    local sec = weap.SecondaryValue
    local knife = weap.KnifeValue
    local boo = game.Lighting.Guns:FindFirstChild("" ..main)
    local boop = game.Lighting.Guns:FindFirstChild("" ..sec)

	
	local c = boo:clone()
	c.Parent = player.Backpack
	local d = boo:clone()
	d.Parent = player.StarterGear

	local e = boop:clone()
	e.Parent = player.Backpack
	local f= boop:clone()
	f.Parent = player.StarterGear

	print("gave tools")
end)
1 Like

oh ok. I’m pretty new to functions. Now I kind of get it

No problem remember to mark as solution

1 Like

Also I found a big error. I forgot to add value after Mainval and SecondVal. fixed it

This wouldn’t work, as I just made a test. GUI values like that cannot be read from the server, as demonstrated here. This only prints the data from the second method, which is sending it directly from the remote, while refusing to print the data from your method.
image
image

Here’s my test, in case you’re wondering:
image

-- button script
local btn = script.Parent
local repl = game:GetService("ReplicatedStorage")
local testrem = repl:WaitForChild("test")

btn.Activated:Connect(function()
	testrem:FireServer(btn.Parent.TextBox.Text)
end)
-- server script
local repl = game:GetService("ReplicatedStorage")
local testrem = repl:FindFirstChild("test")

testrem.OnServerEvent:Connect(function(player, remdata)
	print(player.PlayerGui.ScreenGui.Frame.TextBox.Text .." || "..remdata)
end)

This setup wasn’t even needed in theory, as studio’s server view directly shows this:
image

In short, the data itself has to be sent through the remote, and not read from the server as you’re doing.

1 Like

worked perfectly fine for me though.