For loop isn't responding!

This is inside a local script,

local startFrameExit = startFrame.Exit.Button
local infoFrameExit = infoFrame.Exit.Button


local start = script.Parent.Start.Button
local market = script.Parent.Market.Button
local infoButton = script.Parent.HowToButton.Button

local Buttons = {start, market, infoButton, startFrameExit, infoFrameExit}

for i,v in pairs(Buttons) do
	v.InputBegan:Connect(function(inp)
		if inp.UserInputType == Enum.UserInputType.MouseButton1 and inp.UserInputType == Enum.UserInputType.Touch then
			v:TweenPosition(UDim2.new(0,0,0,0), Enum.EasingDirection.In, Enum.EasingStyle.Sine, 0.1, true)
		end
	end)
	v.InputEnded:Connect(function(inp)
		if inp.UserInputType == Enum.UserInputType.MouseButton1 and inp.UserInputType == Enum.UserInputType.Touch then
			v:TweenPosition(UDim2.new(0,0,0,-0.1), Enum.EasingDirection.In, Enum.EasingStyle.Sine, 0.1, true)
			if i == 1 then -- Start Button
				startFrame.Visible = true
			elseif i == 2 then -- Market Button
			elseif i == 3 then -- Info Button
				infoFrame.Visible = true
			elseif i == 4 then -- StartExit Button
				startFrame.Visible = false
			elseif i == 5 then -- InfoExit Button
				infoFrame.Visible = false
			end
		end
	end)
end

my inputs are not giving any signals so the tweens and what not arn’t working.

1 Like

Ok but why are you trying to detect both the MouseButton1/Touch types? Can’t you just use the or statement to detect if the Player is on PC or Mobile?

3 Likes
if inp.UserInputType == Enum.UserInputType.MouseButton1 and inp.UserInputType == Enum.UserInputType.Touch then

I would suggest using or since using and will return false everytime since they cannot be true at the same time

1 Like

opsies didn’t noticed that was suppose to be or

1 Like

Silly mistakes, My bad! Sorry for disturbing!

Yeah, the or statement just basically passes on to the next conditional check if the first one hasn’t met the correct requirements

Example:

local Number = 90

if Number == 90 and Number == 50 then
    print("We have entered into a parallel universe")
end

That wouldn’t really work, since both of those statements are trying to check if the variable is the same of 2 different numbers

BUT

local Number = 90

if Number == 90 or Number == 50 then
    print("We have entered into a parallel universe")
end

This will work because we’re checking if either the Number is equal to 90 or 50

I hate formatting on mobile

1 Like

Also to add on to @JackscarIitt 's post you can use () to check a group of variables

if player.Name == 'Dandcx' or player.Name == 'Jackscarlett' then
  -- do something
end

instead we can do

if player.Name == ('Dandcx' or 'Jackscarlett') then
  -- do something
end

This isn’t much use to the thread its just nice to know

1 Like

I already know about this, but thanks a lot for discribing it. I didn’t saw that I used and statement and was checking other things to see what wasn’t working and totally forgot that I put and except putting or

1 Like

I actually didnt knew about this, Thanks a lot this might actually make my script a lot nicer to be honest!