Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

UI help? Touched events?

**[READ] ** What I'm attempting to do is when I walk a part the GUI comes up on my screen and when I walk away (not touching the part) the GUI lowers out of view. Im sure Im going at this the wrong way, or my mind is just being slow today. I have no errors, so no worries about that.

When I walk on the brick it comes up, but when I walk away it will not go away. Help? Ideas? ANything to set me on the correct path will be helpful.

Server code..

local Players = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")
 local CS = RS:WaitForChild("CrossServer")
  local Open_UI = CS:WaitForChild("Open UI")

script.Parent.Touched:connect(function(obj)
	if obj ~= nil and (obj.Parent) ~= nil then
		local plr = Players:GetPlayerFromCharacter(obj.Parent)
		if plr ~= nil then
			Open_UI:FireClient(plr, true)
		end
	end
end)

script.Parent.TouchEnded:connect(function(obj)
	if obj ~= nil and (obj.Parent) ~= nil then
		local plr = Players:GetPlayerFromCharacter(obj.Parent)
		if plr ~= nil then
			Open_UI:FireClient(plr, true)
		end
	end
end)

Local code

local ShopOpen = false

local RS = game:GetService("ReplicatedStorage")
 local CS = RS:WaitForChild("CrossServer")
  local UI_Open = CS:WaitForChild("Open UI")

local UI = script.Parent
local MainFrame = UI:WaitForChild("MainFrame")
 local MenuBar = MainFrame:WaitForChild("MenuBar")

local UpdatePos = function()
	if ShopOpen == true then
		MainFrame:TweenPosition(UDim2.new(.5,-300,.5,-200))
	else
		MainFrame:TweenPosition(UDim2.new(.5,-300,1,400))
	end
end

UpdatePos()
UI_Open.OnClientEvent:connect(function(Bool)
	ShopOpen = Bool
	UpdatePos()
end)

6 comments

0

I was having a problem with touchended also. Solution would be really nice.

0

Debounce Touched until TouchEnded fires

0

Yeah, You need a debounce

0

Im trying to work around debounce. This will be a fully functional game so the Debounce would need to be a table for each user. Thats what I DONT want to do.

0

Line 19. I'm assuming it should be false, not true.

1 answer

✓ Accepted answer

If you still need this answered, which I assume you don't, but if you do, simply change line 19 to:

			Open_UI:FireClient(plr, false)

And that should fix it.

1 comment

0

I didnt but since you answered it correctly, accepted! :)

This discussion is preserved as it was. New answers, comments, and votes are closed.