I have this object value that determines what the player currently has equipped, but I'm trying use it in scripts on the server side. The problem is that the value is being set on the client side, and on the server side, it is set to nil. I tried making a script to set in on the server side but it doesn't work.
The script that should set in on the server side:
local event = game.ReplicatedStorage.invEquip
event.OnServerEvent:Connect(function(player, set)
print(set)
print(player)
game.ReplicatedStorage.equipped.Value = set
end)
In this script, player is the actual player, and set is what I want to set the value to. Problem is that it says set is nil although it shouldn't be.
Here is the client-side code:
local equipedValue = game.ReplicatedStorage.equipped
local invEquip = game.ReplicatedStorage.invEquip
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
if equipedValue.Value == script.Parent then
invEquip:FireServer(nil)
equipedValue.Value = nil
equipedValue.ImageLabel.Image = ("")
elseif equipedValue.Value ~= nil then
local success = game.ReplicatedStorage.craftFunction:Invoke(equipedValue.Value, script.Parent)
if success then
end
else
equipedValue.Value = script.Parent
invEquip:FireServer(script.Parent)
-- this is what is being fired
end
end)

1 comment
I'd say to just cut out the client script and use server?