How do i make a value that apply to only the player without influence for other player? Ex: if the person do the quest give the money only for this player. LocalScript? Special location? Its really simple but i dont know what to do...
we need a Touched
function to do this which means we need debounce
so they can only get one point per touch and then remove the part we touch
01 | local player = game.Players.LocalPlayer |
02 | local part = game.Workspace.Part -- the part to be touched to get objective |
03 | local debounce = false |
04 |
05 |
06 | function removePart() |
07 | part:Destroy() |
08 | end |
09 |
10 | function addPoints() |
11 | --add points |
12 | end |
13 |
14 |
15 | part.Touched:Connect( function () |
well, you need some sort of data keeper, such as a leaderstat or just another number,string, and etc values to keep track of the progress of the player.
but in this example, i assume that you use a leaderstat.
01 | game.Players.PlayerAdded:Connect( function (plr) |
02 | local stat = instance.new( "Folder" ,plr) |
03 | stat.Name = "leaderstat" |
04 |
05 | local cash = instance.new( "IntValue" ,stat) |
06 | cash.Name = "Cash" |
07 |
08 |
09 | end ) |
10 |
11 |
12 |
13 | function playerFinishedQuestOrWhatever(plr) |
14 | local points = 20 |
15 |
16 | local stat = plr:WaitForChild( "leaderstat" ) |
17 | local cash = stat.Cash |
18 |
19 | cash.Value = cash.Value + points |
20 | end |
this will only add points to a specific player so when you call playerFinishedQuestOrWhatever()
and give it a player object as an argument., it will only add points to that player's cash
this is just an example of how you could do it... for more help go here