I have a LocalScript, that, when it is run, will fire a RemoteEvent to a value. But the ServerScript I have written won't detect the RemoteEvent firing and change the value!
Here are the two scripts:
LocalScript
----------Change Value Non-Locally----------- local remote = game.ReplicatedStorage.sendData local valueToChange = workspace.InvetoryBoxes.Invetory1.InvetoryBox1.Occupied.Value valueToChange = true remote:FireServer(valueToChange) print("Fired!")
ServerScript
local remote = game.ReplicatedStorage.sendData local valueToChange = workspace.InvetoryBoxes.Invetory1.InvetoryBox1.Occupied.Value remote.OnServerEvent:Connect(function(valueToChange) local value = workspace.CustomizeBoxes.CustBox1.InvetoryBox1.Occupied value.Value = true end)
Any advice?
This might help, first of all, in the local script, do:
local remote = game.ReplicatedStorage:WaitForChild("sendData")
And in the server-side script, when you send over the remote event, the first parameter is the player and the second is what you sent over from the local script. For example,:
remote.OnServerEvent:Connect(function(player, valueToChange) local value = workspace.CustomizeBoxes.Cust1.InvetoryBox1.Occupied value.Value = true end)
Hope this helped!
Okay, so there are several problems. In the local script, you are sending over the value of the boolValue or in other words, the server script is receiving true. It is not receiving the boolValue itself. In the server script, you don't need to make a local value identifying the value to be changed as the server is already receiving it through the remote event. Finally, the first parameter of the server script on server event will always be the client that fired the remote event. Your revised scripts should look something like this:
local remote = game.ReplicatedStorage.sendData local valueToChange = workspace.InvetoryBoxes.Invetory1.InvetoryBox1.Occupied remote:FireServer(valueToChange)
server
local remote = game.ReplicatedStorage.sendData remote.OnServerEvent:Connect(function(clientThatFired,valueToChange) valueToChange.Value = true end)
Let me know if you have any questions.