Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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)

1 comment

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

This discussion is preserved as it was. New answers, comments, and votes are closed.