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

How do I make this script find the player that touched it?

Asked by
Prioxis 673 Moderation Voter
10 years ago

I need help on line 5 how do I find the localplayer that touched it based off of line 5?

function onTouched(hit)
game.Players:FindFirstChild
script.Parent.Transparency = 1
script.Parent.CanCollide = false
game.Players:FindFirstChild -- part of script I need help on

end


script.Parent.Touched:connect(onTouched)

1 answer

Log in to vote
0
Answered by 10 years ago

I did add the closing door part (assuming the parent is a door) but that shouldn't be hard for you to do.

local debounce = true
local TimeBe4ReUse = 2
function onTouched(part)
    if not debounce then return end
    local human = part.Parent:findFirstChild("Humanoid")
    if human then
        debounce = false
        script.Parent.Transparency = 1
        script.Parent.CanCollide = false
        local plr = game.Players:GetPlayerFromCharacter(part.Parent)
        --plr. do stuff here C:
        print(plr.Name)
    end
    wait(TimeBe4ReUse)
    debounce = true
end

script.Parent.Touched:connect(onTouched)
0
It was not a door it was a money bag I was trying to make it to where when you touch the money bag it dissapears and you get money Prioxis 673 — 10y
Ad

Answer this question