Value not changing via Remote Event

I have multiple “ribbons”, and want to simplify the server-side of the remote event by having it make the value of their ribbon true/false upon clicking on a button within a GUI. Which that button then fires off the name of that GUI to make the value either true or false.

However I get this error that “ribbon” is not a valid member of folder “Ribbons”

As seen here:

SERVER SCRIPT:

local function getPlayers(text)
	if text ~= nil and type(text) == "string" then
	for i,v in pairs(game.Players:GetPlayers()) do
		if string.lower(text)==string.lower(v.Name) then
			return v
		end
	end
	end
	return nil
end


local webhook = "[REMOVED FOR DEVFORUM POST]"

local FloodCheck = require(game.ServerScriptService.RemoteFloodCheck)

local RIBBONS = game.ReplicatedStorage.RIBBONS


game.ReplicatedStorage.RIBBONS.OnServerEvent:Connect(function(player, send, ribbon)
	if FloodCheck:Check(player, RIBBONS, 0.08333) then
		local player2 = getPlayers(send)
		if player2 then
			if player:GetRankInGroup(4219097) >= 235 then
				if player2:WaitForChild("Ribbons").ribbon.Value == false then
					print("is false")
					player2:WaitForChild("Ribbons").ribbon.Value = true
					print("made true")
				else
					print("was true")
					player2:WaitForChild("Ribbons").ribbon.Value = false
					print("made false")
					end

					local data2 = {
						content = player.Name.." has given "..player2.Name.." the "..ribbon..""
					}
					data2 = game:GetService("HttpService"):JSONEncode(data2)
					game:GetService("HttpService"):PostAsync(webhook,data2)
			end
			end
		end
end)

LOCAL SCRIPT

script.Parent.MouseButton1Click:Connect(function()

	local send = script.Parent.Parent.username.Value
	if game.Players:FindFirstChild(send) then
		local ribbon = "honorableservice"
		game.ReplicatedStorage.RIBBONS:FireServer(send, ribbon)
			script.Parent.Parent.userna.Text = ''
		end
end)

Your server side code is trying to change the value of an instance that we don’t know the behaviour of because you didn’t provide where Player.Ribbons.ribbon is created and how it’s used across other scripts.

		if player:GetRankInGroup(4219097) >= 235 then
			if player2:WaitForChild("Ribbons")(ribbon).Value == false then
				print("is false")
				player2:WaitForChild("Ribbons")(ribbon).Value = true
				print("made true")
			else
				print("was true")
				player2:WaitForChild("Ribbons")(ribbon).Value = false
				print("made false")
				end

I have changed it to what you see above, and this is the new error I get:

the local script is still seen as:

script.Parent.MouseButton1Click:Connect(function()

	local send = script.Parent.Parent.username.Value
	if game.Players:FindFirstChild(send) then
		local ribbon = "honorableservice"
		game.ReplicatedStorage.RIBBONS:FireServer(send, ribbon)
			script.Parent.Parent.userna.Text = ''
		end
end)

and as seen here, the values are a member of a folder called “Ribbons” located within the player:

Screenshot_299

Ohh I get it now, you are calling the Ribbons folder like it’s a function. You are not referencing one of it’s children.

Player.Ribbons(ribbon) --don’t do this, double brackets indicate that you are calling a function
Player.Ribbons[ribbon] --do this, this syntax indicates that you are referencing a value inside a table
Player.Ribbons:FindFirstChild(ribbon) --FindFirstChild returns the child with the name of the first parameter you put into it

Simple syntax mixup :slight_smile:

1 Like

Works! Thank you so much for the help, funny how one little thing can mess up so much haha.

1 Like