My gun system does not support mobile, So I have decided to make a button that only mobile players can see, but how do I make it shoot (by making it think that the touch was a click)
You could just create a variable for detecting the MouseButton1Down
& MouseButton1Up
events.
You could also make it work with the TouchTap
& MouseButton1Click
events…
Sorry, Can you explain more? I have never really even touched input scripts, How would I detect it?
does your gun fire once when you hold your mouse’s left click? or fires only once?
It is quite simple, to be honest.
An example is this:
local button = --your variable--
local HoldingMouseDown = false
local ButtonWasTapped = false
button.MouseButton1Click:Connect(function()
HoldingMouseDown = true
end)
button.MouseButton1Down:Connect(function()
HoldingMouseDown = false
end)
While the mouse is being held down:
while HoldingMouseDown == true do
-- whatever you want to do here --
end
MouseButton1Down()
should return the same results if the button was held down on mobile
not sure but u can use ContextActionService
i don’t think that his problem, he said that he already made the button but he doesn’t know how to make it shoot.
yeah, you can bind the action…
He could propably do something like this:
local button = --your variable--
local ButtonWasHeld = false
button.MouseButton1Down:Connect(function()
ButtonWasHeld = true
end)
while ButtonWasHeld == true do
-- whatever you want to do here --
end
his problem is probably firing the remote event to the server along with the shooting position
Depends on the gun, Sometimes It can be an automatic gun, Sometimes not.
Can you make it so it just clicks?
My gun only works if its equipped and you click, nothing else.
If they equip it, Instead of doing that, Why can’t I just mimic it clicking?
Connect the button’s MouseButton1Click
/Activated
event/signal to the function that handles firing of the gun.
local Script = script
local Button = Script.Parent
local function FireGun()
--Function that performs the gun's 'Fire' action.
end
Button.Activated:Connect(FireGun)
Why can I not just do
if press button
click
Or is that not possible?
What is that may I ask?