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

How to show the winning players name?

Asked by 2 years ago

Hello I am trying to make a system close to the one in rage runner where your name is displayed if you win

i have made a script that will add a win when you hit a part but i want the winning players name to be shown to everyone as well.

this is what i have done so far

local player = game:GetService("Players")
local pad = script.Parent -- Path to coin
local notify = game.ReplicatedStorage.Notify

local used = false

function giveCoin(part)
    if part.Parent:FindFirstChild("Humanoid") == nil or used == true then
        return
    end
    used = true
    local player = player:GetPlayerFromCharacter(part.Parent)
    player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1

    pad:Destroy()
end

pad.Touched:Connect(giveCoin)


the notify variable is a stringValue in replicated storage and i want the value of notify to change to the players name when they hit the block

can you help me

thanks :)

1 answer

Log in to vote
0
Answered by 2 years ago
local player = game:GetService("Players")
local pad = script.Parent -- Path to coin
local notify = game.ReplicatedStorage.Notify

local used = false

function giveCoin(part)
    if part.Parent:FindFirstChild("Humanoid") == nil or used == true then
        return
    end
    used = true
    local player = player:GetPlayerFromCharacter(part.Parent)
    player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1

    notify.Value = player.Name -- just sets the value of your string to the name of the player! :) Easy!

    pad:Destroy()
end

pad.Touched:Connect(giveCoin)


Ad

Answer this question