So I've tried to do this but it seems it will work inside Studio but not inside the actual game, so it must be something to do with FE, so could someone please help me make it work with FE?
Client Side:
local codes = script.Parent.Parent.Codes -- location of the codes local ds = game:GetService("DataStoreService") local store = ds:GetDataStore("CodeSave") script.Parent.MouseButton1Down:Connect(function() if script.Parent.Parent.codeBox.Text == "Alpha" then if codes.Alpha.Value == true then script.Parent.Parent.codeBox.Text = "Already Redeemed!" end if codes.Alpha.Value == false then codes.Alpha.Value = true game.ReplicatedStorage.GiveMoney:FireServer() script.Parent.Parent.codeBox.Text = "Redeemed!" end end end)
Server Side:
game.ReplicatedStorage.GiveMoney.OnServerEvent:connect(function() local codes = game.StarterGui.CodeSystem.RedeemArea.Codes game.Players.LocalPlayer.leaderstats.Credits.Value = game.Players.LocalPlayer.leaderstats.Credits.Value + codes.Alpha.Reward.Value end)
You can't access local player from a server script. It makes no sense since the script is on the server not a specified client.
When you fire a remote event it automatically passes the player that fired the event as the first argument.
game.ReplicatedStorage.GiveMoney.OnServerEvent:connect(function(player) local codes = game.StarterGui.CodeSystem.RedeemArea.Codes player.leaderstats.Credits.Value = player..leaderstats.Credits.Value + codes.Alpha.Reward.Value end)