I’m trying to transfer a value which is in server storage to a local script so I decided to use remote events. I made a event that should get the MaxAmount and then send it to the client but it doesn’t change.
Normal script:
local function(player, itemname, ItemAmount)
local item = game.ServerStorage.Inventory:FindFirstChild(player.Name):WaitForChild("Data"):WaitForChild("Items")[itemname]
local itemCore = item
local MaxAmmount = item:WaitForChild("Amount").Value
C1:FireClient(player, itemCore, MaxAmmount)
Local script:
local SelectedItem
local MaxAmountVal = 2
C1.OnClientEvent:Connect(function(itemCore, MaxAmmount)
MaxAmountVal = MaxAmmount
SelectedItem = itemCore
end)
c1 is the remote event. I want the MaxAmountVal to change depending on the value MaxAmount on the server side.
im getting item from a script in serverscriptservice and im getting the value from the amount from item. then in the local script i want to get that value
itemCore is a reference to an instance in ServerStorage. Since ServerStorage is not replicated to the client, the client will resolve the reference to nil. This means SelectedItem will always be nil.
However, you appear to be replicating MaxAmmount correctly. Sending Value instead of a reference to the instance. Perhaps you meant to do this for itemCore?