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

local player = game.Players.LocalPlayer
local part = game.Workspace.Part -- the part to be touched to get objective
local debounce = false


function removePart()
       part:Destroy()
end

function addPoints()
 --add points
end


part.Touched:Connect(function()
       if not debounce then
debounce = true
         addPoints()
            wait()
         removePart() -- remove the part so they can only get points / the objective once
         debounce = false
         end
end)
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.

game.Players.PlayerAdded:Connect(function(plr)
    local stat = instance.new("Folder",plr)
    stat.Name = "leaderstat"

    local cash = instance.new("IntValue",stat)
    cash.Name = "Cash"


end)



function playerFinishedQuestOrWhatever(plr)
    local points = 20

    local stat = plr:WaitForChild("leaderstat")
    local cash = stat.Cash

    cash.Value = cash.Value + points
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

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