Answered by
2 years ago Edited 2 years ago
Good day, hope you are doing well.
Basically, I think the issue is happening because you are connecting the touch event to the brick itself. This means that the event fires, when anybody touches the brick.
Instead, you have to check if that individual player touched that brick.
01 | script.Parent.Frame.Visible = false |
03 | local brick = workspace.Shop |
04 | local player = game.Players.LocalPlayer |
08 | brick.Touched:Connect( function (hit) |
09 | if hit and hit.Parent:FindFirstChild( "Humanoid" ) then |
10 | local humanoid = hit.Parent:FindFirstChild( "Humanoid" ) |
11 | if humanoid.Parent.Name = = player.Name then |
12 | if debounce = = false then |
14 | script.Parent.Frame.Visible = true |
20 | brick.TouchEnded:Connect( function (hit) |
21 | if hit and hit.Parent:FindFirstChild( "Humanoid" ) then |
22 | local humanoid = hit.Parent:FindFirstChild( "Humanoid" ) |
23 | if humanoid.Parent.Name = = player.Name then |
24 | if debounce = = true then |
26 | script.Parent.Frame.Visible = false |
I tried replicating this scenario in Roblox Studio, and this is what worked for me. The debounce variable is optional, but I would keep it to yield more accurate results and for performance.