Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does my server script ignore a line of code that takes away coins from a player?

I am almost done making a shop GUI and I just need to make it so it takes away the players' coins when they purchase an item. The server script somehow ignores line five and doesn't remove the current coins that the player has. I need someone's help!

local giveWeapon = script.Parent:WaitForChild("GiveWeapon")
local others = script.Parent.Parent:WaitForChild("Others")

giveWeapon.OnServerEvent:Connect(function(player, leaderboard, weapon)
	leaderboard.Coins.Value = leaderboard.Coins.Value - others.Cost.Value
	weapon:Clone().Parent = player.Backpack
	weapon:Clone().Parent = player.StarterGear
end)

P.S. The server script is inside of the GUI and there are no errors in the output. I tried everything and I couldn't find any errors.

4 comments

0

Check the output? For errors and/or warnings?

0

There are no errors in the output. I tried everything and I couldn't find any errors.

0

I forgot what the parameters are, but u should try subtracting the player's coins in the localscript.

0

Did you try to see if others.Cost.Value is not 0?

1 answer

✓ Accepted answer

You cant change leaderBoard.Coins.Value on the client side. You have to change it on the server side.

You should move all of the code (changing coins, giving weapon etc.) to the SERVER. It's a bad idea to do it on the client anyways

3 comments

0

You do know he said its a server script

0

Exactly, LOL.

0

LazokkYT's comment helped me and I figured it out a while ago so I will just accept this answer so people won't stop answering this.

This discussion is preserved as it was. New answers, comments, and votes are closed.