How Do I give a player points on the server

Hello, I was wondering how I could give a player points on the server when they touch a part? Thanks for helping,


1 Like

You can make Click Detector then you’ll need to insert script then make click function that will give you + 1 point or what ever. If you need code dm me (smarsh1#4462).


No I mean when a player touches a part with a body part.

Then you’ll need to make on touch function!

This might help:

So would this be the code.


The code could look something like this on the server:

    PlayerPoints = PlayerPoints + 1

Is that full code?
(30 characters)

yes that is full code
(30 Characters)

Make touch function if touched then you reference leaderstats + 1

The thing is i’m giving them on the server.

That shouldn’t be an issue. I recommend using DataStoreService to store data.

I am on mobile, so apologies if I write something incorrectly. I see some stuff that are incorrect.

For one, the Touched event can be on the server instead of the client.

For two, the Touched event doesn’t have a OnServerEvent, so you can remove that and go straight to connect.

So it should look something like this (on the server):

    -- Do Stuff

If you want to get the player, you can do local Player = game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent), and if it isn’t nil, then it’s the player that touched it.


Where should the script be located? And what type of script should it be?

It should be a normal script and be located either in ServerScriptService or under the part. If it is under the part, then you can use script.Parent.Touched instead. It should not be a local script.

In short, anywhere that a normal script can run on.

This is the basic approach, but there is an issue. If this isn’t a local script, then there is no way that PlayerPoints can be referenced since you do not fetch the player.

I made a regular script and put it in the part and changed it to script.Parent.Touched and then moved it to ServerScriptService and then changed it to the original code and nothing worked.

No no. The part should be in the workspace. The script is in different locations. Put the script under the part if you use script.Parent.Touched.

Yes, it was just an example script.

Yes this is the code I used before and it didn’t work

   	game.Players.LocalPlayer.leaderstats.Pong.Value = game.Players.LocalPlayer.leaderstats.Pong.Value + 15

And it says attempt to call index nil with leaderstats