script.Parent.Touched:Connect(function() game.Players.LocalPlayer.leaderstats.Cash.Value = game.Players.LocalPlayer.leaderstats.Cash.Value + 1 end)
Cash
script.Parent.Parent.A.B.MouseButton1Click:Connect(function() local waitTime = math.random(3,5) local subscriberAdd = math.random(1,3) while true do wait(waitTime) game.Players.LocalPlayer.leaderstats.Subscribers.Value = game.Players.LocalPlayer.leaderstats.Subscribers.Value + subscriberAdd wait(2) end end)
A and B are added in because I dont want game idea stolen
Even when I do the same thing in the same script cash dosen't work
I'm assuming that the first one is in a localscript, as it references the part as script. Parent. You would have to make it a localscript to index localplayer, so here is my solution.
loccal plr=game.Players.LocalPlayer local cash=pls.leaderstats.Cash.Value local part=--your part script.Parent.Touched:Connect(function() cash.Value = Cash.Value + 1 end)
This is definitely not how this is supposed to be done. There are 4 things you need to know.
LocalPlayer can only be accessed from LocalScript. This makes sense as the server script does not know which player you are pointing at. If someone on the phone asks who am I, then it would not make sense to say “Me” since “Me” could be said by anyone. You need to remember the server script as an omnipotent Roman god which is not associated with any player.
All changes made to the game MUST BE DONE ON SERVER SCRIPT. You can not make any changes from localscript. Localscript is for the mortals, Script is for the gods. Use LocalScript for GUIs and input.
Use remote functions and events (https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events). The server won’t hold everybody’s hands, so it is your responsibility to send data through remotes from their source to where they are needed. For example: you generate an array of randomly generated terrain from the server. It is your job to push those keys and do idiotRemote:InvokeClient(player, stuff, stuff), so that the array gets visualized on client.
Use OOP. Object oriented programming is the act of processing objects to get all kinds of data without repeating yourself. OOP is so prevalent there is a Wikipedia article on it. OOP is your friend. Do not abandon it. Right now your code is good but I guarantee that if you keep adding features without ModuleScripts, your code will turn into an illegible, inefficient, pile of mess.
If you follow these 4 pieces of advice then you have a good chance at becoming featured. I personally have never hit the front page in so long. Back then it was much easier