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

Trying to enable GUI when player enters area?

Asked by 5 years ago

Hi, so basically I'm trying to create a script that enables a GUI when a player enters an area. Right now I've got a part in the workspace and this script in it along with a NumberValue.


script.Parent.Touched:connect(function(hit) local human = hit.Parent:FindFirstChild("Humanoid") if human then local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then print("In Zone") script.Parent.Value.Value = 1 end end end) script.Parent.TouchEnded:connect(function(hit) local human = hit.Parent:FindFirstChild("Humanoid") if human then local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then print("Left Zone") script.Parent.Value.Value = 0 end end end)

The script works alright but whenever the player jumps the GUI is disabled, there is also some other annoying bugs like when the player goes to the edge of the part and enters again without fully leaving contact with it which results in the GUI being disabled. If there is a more efficient way of doing this please let me know. Any help would be greatly appreciated.

0
raycasting maybe? DinozCreates 1070 — 5y
0
Thanks I'll look into that SpacePuppyMan 31 — 5y
0
It makes a lot more sense to use a Region3 here. It's practically what they exist for. Give it a look and let me know if you have questions: https://developer.roblox.com/api-reference/datatype/Region3 SummerEquinox 643 — 5y
0
You're right summer, good call. Both CAN be used but i agree thats the better option. DinozCreates 1070 — 5y

Answer this question