0

# How to get the player from the character?

In my win system. I made a local script in startergui to show the person who won. The issue is that since it is in startergui, the local script is cloned to everyone. I need it to just show for the winner of the round.

Heres my script: (Btw, I don't actually have anything yet because I'm completely stumped on how I would reference the player from the character)

place = CFrame.new(102.4, 205.2, 210.8)

script.Parent.Touched:connect(function(p)

local humanoid = p.Parent:findFirstChild("Humanoid")

if (humanoid ~= nil) then

humanoid.Torso.CFrame = place

game.StarterGui.Win.showwin.Parent =

_G.InsideBossBattle = true
game.ReplicatedStorage.NotWonYet.Value = false

game.ReplicatedStorage.ShowWin:FireAllClients()

local target = CFrame.new(114.2, 205.8, 211.7)
for i, player in ipairs(game.Players:GetChildren()) do

if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then

player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
end
end

game.Workspace.WinningMusic.Playing = true
game.Workspace.BGMusic.Playing = true
game.Workspace.GameMusic.Playing = false

for i=1, 20 do
game.Workspace.BGMusic.Volume = game.Workspace.BGMusic.Volume - 0.05

game.Workspace.WinningMusic.Playing = true
game.Workspace.WinningMusic.Volume = game.Workspace.WinningMusic.Volume + 0.05

wait(0.3)

end
wait(3.5)

game.Workspace.BGMusic.Playing = true

for i=1, 20 do
game.Workspace.BGMusic.Volume = game.Workspace.BGMusic.Volume + 0.05

game.Workspace.WinningMusic.Volume = game.Workspace.WinningMusic.Volume - 0.05

wait(0.3)

end
game.Workspace.WinningMusic.Playing = false
game.Workspace.WinningMusic.TimePosition = 54

humanoid.Parent.showwin.Parent = game.StarterGui

end


end)

1

You can also do

game.Players[ch.Name]


This is because using . in place of [] is a shortcut. f you aren't using a literal string, use []

0
Thanks, that fixed most of my script. Desmondo1 36 — 4d
game.Players:GetPlayerFromCharacter(ch)