How do I get the player from their character or character from the player?

HellO! I’m trying to make a obby game, a Tiered one. The issue is this script wont work:

local Character = script.Parent
local Head = script.Parent:WaitForChild("Head")
local Torso = script.Parent:WaitForChild("Torso")
local HumanoidRootPart = script.Parent:WaitForChild("HumanoidRootPart")
local LeftLeg = script.Parent:WaitForChild("Left Leg")
local RightLeg = script.Parent:WaitForChild("Right Leg")
local LeftArm = script.Parent:WaitForChild("Left Arm")
local RightArm = script.Parent:WaitForChild("Right Arm")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CheckPoint1Event = ReplicatedStorage:WaitForChild("CheckPoint1Event")

local function LegsTouched(hit)
	if hit.Name == "SpawnLocation" then
		CheckPoint1Event:FireClient(player)
	end
end

LeftLeg.Touched:Connect(LegsTouched)
RightLeg.Touched:Connect(LegsTouched)

How am I supposed to get the player from their character?

1 Like

Do you mean this?

1 Like

Always make sure to place a local script in StarterPlayerScripts, not StarterCharacterScripts. It works, but I prefer player scripts instead.

How to get player’s character through player;

local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

I don’t think you would need a reference for getting the player’s through their character. I don’t find any use in that. But if you want to do it anyway, research here; Players | Roblox Creator Documentation

1 Like