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

Touched repeat problem solution?

Asked by 4 years ago
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

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 Dovydas1118 1495 — 4y

1 answer

Log in to vote
0
Answered by
MattVSNNL 620 Moderation Voter
4 years ago

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

Ad

Answer this question