So i have trying to do this script but i keep getting this error pls help me
01 | script.Parent.MouseButton 1 Click:connect( function () |
02 | local RS = game:GetService( "ReplicatedStorage" ) |
03 | local item = RS:WaitForChild( "Gravity Coil" ) |
04 | local price = 50 |
05 | local player = game.Players.LocalPlayer |
06 | local stats = player:WaitForChild( "leaderstats" ) |
07 |
08 | if stats.Points.Value = = price then |
09 | stats.Points.Value = stats.Points.Value - price |
10 | local cloned = item:Clone() |
11 | local cloned 2 = item:Clone() |
12 | cloned 2. Parent = player.Backpack |
13 | cloned.Parent = player.StarterGear |
14 | end |
15 | end ) |
Well, first off, it would be nice if you could put it in a code block because it would be way easier to read. Also, If you have your code written out like that and it's not a copy+paste error, I suggest taking a bit of time fixing it up so it's easier to read.
Since it's hard to read and you didn't give much information, I can't help very well. But to me, it looks like you may be trying to access the local player from a server script. If it's in a server script you can't use game.Players.LocalPlayer to get the local player. If it's something to do with the player, always use local scripts.