RemoteEvent:Client To Server

So i want to send a message from client to server,
by “message” i meant like,

Statement
when a player clicked a gui button, da game.Players.LocalPlayers.Folder.armorvalue.Value will be changed,

so i want to say the above statement to the server,

What i have done
I fired a event from a local script

My Problem / wanted help for
but how do i like receive it? from the server,
game.ReplicatedStorage.ServerEvent.OnSeverEvent something like that?

Pls help me, thanks in advance and Have A Nice Day
Thanks For Reading,
The Spikey Man

You can listen for it on the server like so:

Remote.OnServerEvent:Connect(function(player)
   -- check if the remote was fired legally from the client
   -- if it was, then...
   -- look for the armour folder value and change it to your needs
end)
1 Like

I tried that but gave me error, of RBX scriptsignal value error something, pls holp me

It would be easier for people to help you if you show us the code and output.

may we see the code ? maybe you set it up wrong

Client:

local value = 10

script.Parent.MouseButton1Click:Connect(function()

game.ReplicatedStorage:WaitForChild("RemoteEvent"):FireServer(value)

end)

Server:

game.ReplicatedStorage:WaitForChild("RemoteEvent").OnServerEvent:Connect(function(player, value)

game.Players[player].Folder.armorvalue.Value == value

end)

I dont really know what u want to do if u could explain it better it would be better

local script

	-- Purchase Btn --
	PurchaseBtn.MouseButton1Click:Connect(function()
		local Plr = game.Players.LocalPlayer
		if Plr:FindFirstChild("leaderstats").Cash.Value >= Price then
			if Plr:FindFirstChild("ArmorFolder").BronzeArmor.Value == false then
				Plr:FindFirstChild("ArmorFolder").BronzeArmor.Value = true
				local Cash = Plr:FindFirstChild("leaderstats").Cash
				local Now = Cash.Value - Price
				Cash.Value = Now
				game.ReplicatedStorage.ServerEvent:FireServer(Plr)
			end
		end
	end)

server side

game.ReplicatedStorage.LocalEvent.OnServerEvent(function(plr)
	local EQ = plr:FindFirstChild("Equiptence")
	local ArmorFolder = plr:FindFirstChild("ArmorFolder")
	local hasEquip = EQ:FindFirstChild("hasEquipped")
	ArmorFolder:FindFirstChild("BronzeArmor").Value = true
	hasEquip:FindFirstChild("BronzeArmor").Value = true
end)

oh wait the plr isnt right lemme correct that and see

Your firing “ServerEvent” from the client, and listening for “LocalEvent” on the server.

Could you show the variables in your script?

ServerEvent is the remote event, i accidently wrote localevent,

Updated script still the same error though

game.ReplicatedStorage.ServerEvent.OnServerEvent(function(Plr)
	local EQ = Plr:FindFirstChild("Equiptence")
	local ArmorFolder = Plr:FindFirstChild("ArmorFolder")
	local hasEquip = EQ:FindFirstChild("hasEquipped")
	ArmorFolder:FindFirstChild("BronzeArmor").Value = true
	hasEquip:FindFirstChild("BronzeArmor").Value = true
end)
-- Purchase Btn --
PurchaseBtn.MouseButton1Click:Connect(function()
	local Plr = game.Players.LocalPlayer
	if Plr:FindFirstChild("leaderstats").Cash.Value >= Price then
		if Plr:FindFirstChild("ArmorFolder").BronzeArmor.Value == false then
			Plr:FindFirstChild("ArmorFolder").BronzeArmor.Value = true
			local Cash = Plr:FindFirstChild("leaderstats").Cash
			local Now = Cash.Value - Price
			Cash.Value = Now
			game.ReplicatedStorage.ServerEvent:FireServer(Plr)
		end
	end
end)

Add some prints in your code, see if the remote even gets fired in the first place.

Ok lemme add prints and come back

By printing u mean like dis right, sorry if im domb

	-- Purchase Btn --
	PurchaseBtn.MouseButton1Click:Connect(function()
		local Plr = game.Players.LocalPlayer
		if Plr:FindFirstChild("leaderstats").Cash.Value >= Price then
			if Plr:FindFirstChild("ArmorFolder").BronzeArmor.Value == false then
				Plr:FindFirstChild("ArmorFolder").BronzeArmor.Value = true
				local Cash = Plr:FindFirstChild("leaderstats").Cash
				local Now = Cash.Value - Price
				Cash.Value = Now
				game.ReplicatedStorage.ServerEvent:FireServer(Plr)
				print("Amogus")
			end
		end
	end)

there u go @zektonn it works

It should be:

game.ReplicatedStorage.ServerEvent.OnServerEvent:Connect(function(Plr)

1 Like

oooo tanks bruv, tanks a lot! :slight_smile: