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

Touched repeat problem solution?

local part = script.Parent

part.Touched:Connect(function(hit)
	local view = hit.Parent:FindFirstChild("Union")
	if view then
		script.Parent.Anchored = true
			print("Player see")
	else
		print("player unsee")
		script.Parent.Anchored = false
		end
end)

i am scripting SCP 173 and in the output only "Player see" repeat while "Player unsee" works only when spawning

1 comment

0

You'll need to do math and use CFrame to see if the player is looking away. I suggest looking at DotProduct to see a player's 'field of view'. https://www.youtube.com/watch?v=BUwAcW_18Ws

1 answer

Try when a player touches it check if it is a player like elseif

local part = script.Parent

part.Touched:Connect(function(hit)
    local view = hit.Parent:FindFirstChild("Union")
    if view then
        script.Parent.Anchored = true
            print("Player see")
    elseif not view then
        print("player unsee")
        script.Parent.Anchored = false
        end
end)

If it errors let me know

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