Ok so I have an object value called "Weapon" and inside of my local script I fire a remote event carrying the weapons value. Now when the server script gets the event and the data with it it cannot find the parent of the parent of object which is the player and I dont think it finds the object either.
This is my local script in the players gui.
local ReplicatedStorage = game:GetService("ReplicatedStorage") local remoteEvent = ReplicatedStorage:WaitForChild("UpgradeEvent") function onClicked() local Weapon = script.Parent.Parent.Weapon.Value print ("EventSent") remoteEvent:FireServer(Weapon) end script.Parent.MouseButton1Down:connect(onClicked)
This is my server script in serverscriptservice.
local remoteEvent = game.ReplicatedStorage.UpgradeEvent local function Upgrade(Weapon) print ("Event Recieved") local player = Weapon.Parent.Parent if player.leaderstats.Money.Value >= 100 then player.leaderstats.Money.Value = player.leaderstats.Money.Value - 100 print ("Player has enough money") local updmg = Weapon.Damage / 5 Weapon.Damage = Weapon.Damage + updmg print ("Upgrade Amount"..updmg) else end end remoteEvent.OnServerEvent:Connect(Upgrade)
This is the error I get because instead of searching for leaderstats in the player it searches for it in the game. Even though in the server script it clearly says
Player = Weapon.Parent.Parent
which if we check in client mode is the player.
error:
leaderstats is not a valid member of DataModel "Battle Ultimates"
The local script does not give any errors as it prints out "Event Sent" and the server script gets the event as it prints out "Event Recieved" But it does not print out the other parts because the error is on line 7 now the error would not happen if it actually understood where player was.