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
01local part = script.Parent
02 
03part.Touched:Connect(function(hit)
04    local view = hit.Parent:FindFirstChild("Union")
05    if view then
06        script.Parent.Anchored = true
07            print("Player see")
08    else
09        print("player unsee")
10        script.Parent.Anchored = false
11        end
12end)

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

01local part = script.Parent
02 
03part.Touched:Connect(function(hit)
04    local view = hit.Parent:FindFirstChild("Union")
05    if view then
06        script.Parent.Anchored = true
07            print("Player see")
08    elseif not view then
09        print("player unsee")
10        script.Parent.Anchored = false
11        end
12end)

If it errors let me know

Ad

Answer this question