So.., I did this after 3 hours failing to do Mouse.Button1Down and Button1Up. I thought it would solve my problem ...
UserInputService = game:GetService("UserInputService") ChargeTime = script.Parent.Configurations.ArrowCharge.Value FireEvent = game:GetService("ReplicatedStorage").BowEvents.FireEvent local ReloadTime = script.Parent.Configurations.ArrowReload.Value local mouse = game.Players:GetPlayerFromCharacter(script.Parent.Parent):GetMouse() local charge = 0 reloading = false holdDown = script.Parent.holdDown.Value local function Press() while UserInputService:IsMouseButtonPressed() == true do print("hold") wait(0.1) end if UserInputService:IsMouseButtonPressed() == false then print("FIRED") end end if UserInputService.InputBegan == Enum.KeyCode.ButtonL1 then print("click") Press() end
It's a charging script for a bow. (It's a local script) What's the problem or is there any workaround?
yikes. The effort was nice but you REALLY should have looked on the wiki or explored the syntax.
here's a template for how you'd use input service with a mouse sorta thing.
local uis = game:GetService("UserInputService") uis.InputBegan:connect(function(input, gp) if gp then return else if input.UserInputType == Enum.UserInputType.MouseButton1 then -- start charging end end end end) uis.InputEnded:connect(function(input) -- optional, turn it into a comment with -- if you dont want this. if input.UserInputType == Enum.UserInputType.MouseButton1 then --stop charging then fire end end)