#Events
Touched is NOT a function, it is an event. When a function is called alongside it, however, the first argument is the part who touched, NOT the Player.
###Ancestry
As I said before, the first argument to the function is the part who touched the part handling the event, meaning if a character touched it, you can reference them.
###Practice
You would have to use if statements, FindFirstChild method, and the GetPlayerFromCharacter method.
Respectively, these are used to:
Check if a condition is met.
Check if a Child exists in a Parent object.
Retrieves the player from a character.
script.Parent.Touched:Connect(function(hit)
local part = script.Parent
part.CFrame = part.CFrame + Vector3.new(0, -8, 0)
player.leaderstats.Power.Value = player.leaderstats.Power.Value + 4
if hit.Parent:FindFirstChild("Humanoid") then
plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
plr.leaderstats.Power.Value = player.leaderstats.Power.Value + 4
end
wait(120)
part.CFrame = part.CFrame + Vector3.new(0, 8, 0)
end)
2 comments
First off, it's not a function, it's an event, and touched returns the part that touched the part handling the event
https://www.robloxdev.com/api-reference/event/BasePart/Touched