Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do i make a value that is apply independant for other player?

Asked by 5 years ago

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...

2 answers

Log in to vote
0
Answered by
AltNature 169
5 years ago
Edited 5 years ago

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

01local player = game.Players.LocalPlayer
02local part = game.Workspace.Part -- the part to be touched to get objective
03local debounce = false
04 
05 
06function removePart()
07       part:Destroy()
08end
09 
10function addPoints()
11 --add points
12end
13 
14 
15part.Touched:Connect(function()
View all 23 lines...
0
thx !! scorpion981 27 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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.

01game.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 
09end)
10 
11 
12 
13function 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
20end

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

0
thx, i will try scorpion981 27 — 5y
0
i just edited the answer User#23252 26 — 5y
0
i just edited the answer User#23252 26 — 5y
0
ok scorpion981 27 — 5y
0
Yes use both these scripts to save it and detect touching AltNature 169 — 5y

Answer this question