I would like to close a Gui when a player is not over or under a brick. This means using part.Position and part.Size. Is there a way to combine these two and use .magnitude to make this statement false?
1 | player = game.Players.LocalPlayer |
2 | flor = game.Workspace.flor |
3 |
4 | while wait( 1 ) do |
5 | if not (player:DistanceFromCharacter(flor.Position)>< = ?) then |
6 | script.Parent.Parent.Visible = false |
7 | end |
8 | end |
Maybe you can cast a ray above the brick to determine if the character is directly above. Here is some sample code.
01 | local Part = workspace:WaitForChild( "PARTNAMEHERE" ) |
02 |
03 | Part.Touched:connect( function (Hit) |
04 | if Hit.Parent:FindFirstChild( "Humanoid" ) ~ = nil then |
05 | local Ray = Ray.new(Part.Position,Part.Position + Vector 3. new( 0 , 50 , 0 )) |
06 | local Hit,Position = workspace:FindPartOnRay(Ray) |
07 |
08 | if Hit then |
09 | -- Your code here |
10 | end |
11 | end |
12 | end |