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

how do i make a brick change the leader stat of a player?

Asked by 8 years ago

i would really like to know how i could do this for example if im making an obby with gamemodes and i want to make the other players notice what gamemode they are in then when the person touches that gamemode brick it changes the stat of the player to say what ever gamemode it is i would do speed run if this is a bad question then im sorry for wasting your time for the people that dont understand anything i mean like a gamemode stat like NOT A LEVEL a other stat my stat that i used in the example was a gamemode like my leader board has this stage and gamemode do you now understand?

0
So you mean like a spawnpoint level? So when u complete a level it says, level 2.. 3.. 4.. 5.. etc. iNicklas 215 — 8y
0
no like a gamemode tordenask 1 — 8y

2 answers

Log in to vote
2
Answered by 8 years ago

Alright, sorry for my previous answer apparently I did not answer the question. So I kind of get what you mean This is my understanding of what you mean.... If you touch a Part for the Normal GameMode then your leaderstats which is called GameMode turns its value to Normal, however if you touch a brick for Advanced GameMode then your leaderstats which is called GameMode changes to Advanced. Alright I am going to script just how you would do it with a brick for the Normal GameMode. I will explain the script inside of the script using comments...

For the following script to work make sure you have a leaderstats script that make a Model called leaderstats and it makes a StringValue called GameMode you may edit the Script at your own leisure. Now then lets get started time to make it so when you touch a Part it changes the StringValue inside of your player to Normal

local part = script.Parent -- Variable for the part which the character is going to touch.

part.Touched:connect(function(hit) -- An anonymous function(Hope you know how to make one)
    local hum = hit.Parent:WaitForChild("Humanoid") -- Variable to confirm it's a humanoid that touches that part.
    if hum then -- If statement(Hopefully you know how to make one)
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent) -- Variable for player using :GetPlayerFromCharacter() method.
        plr.leaderstats.GameMode.Value = "Normal" -- Changes the value of the StringValue
    end
end)

I hope it helped this time.

0
nope not working i did read it all but not working tordenask 1 — 8y
0
why does nobody understand what i mean tordenask 1 — 8y
0
Maybe you can explain it better? KingLoneCat 2642 — 8y
0
i did explain it tordenask 1 — 8y
View all comments (5 more)
0
Yeah but, I said 'explain it better'. KingLoneCat 2642 — 8y
0
now i did explain tordenask 1 — 8y
0
Alright I am going to update my answer and try to explain it better. KingLoneCat 2642 — 8y
0
now it works THANK YOU :D tordenask 1 — 8y
0
Glad I could help. KingLoneCat 2642 — 8y
Ad
Log in to vote
0
Answered by 5 years ago

in the PlayerSetup script on serverScriptServuce put this code

local function onPlayerJoin(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player

local gold = Instance.new("IntValue")
gold.Name = "ORO"
gold.Value = 0
gold.Parent = leaderstats

end

game.Players.PlayerAdded:Connect(onPlayerJoin)

in the brick script put this code

local goldPart = script.Parent local function onPartTouch(otherPart) local partParent = otherPart.Parent local humanoid = partParent:FindFirstChildWhichIsA("Humanoid") local plr = game.Players:GetPlayerFromCharacter(otherPart.Parent) if ( humanoid ) then plr.leaderstats.ORO.Value = plr.leaderstats.ORO.Value + 10 end goldPart:Destroy() end goldPart.Touched:Connect(onPartTouch)

Answer this question