I want to make a function where you can hold down left mouse button or for people with touchscreen without a mouse, it will run if they hold their finger on the screen.
There will be a value in the player’s character called “ShootPower”, which will be set to 20 automatically, the default dribbling power.
I can create everything, except the script for increasing power when someone holds the screen or mouse.
I don’t know why I would call this mean, it’s just advice.
I’m not asking for an entire script, the only thing I need from people viewing, is to show me how to check if a player is holding their mouse or holding the touch screen.
I don’t know how to do this, that’s why I asked the forum.
I could ask ChapGPT, but I actually want to learn how to do it, as I am just a biginner scripter making my own game.
you can use os.clock() for this. to simplify os.clock, it is the amount of cpu used by lua in seconds. we can just think of os.clock() as time. so, we want to get the time between when you press the input and the time when you end the input. that will look like
-- example
local starttime = os.clock() -- time when player first touches screen
inputendedevent:Connect(function()
local timedifference = os.clock() - starttime -- os.clock currently in this event is the time when we end the inputendedevent because it's just constantly counting in seconds outside of our vision.
end)
now we can just use timedifference as the power multiplied by whatever you want if the power isn’t enough
edit: ask questions if you’re confused on anything