I don’t know why but UIS is acting weird.
When I try use it it sometimes just doesn’t work.
It only works if I don’t move I think its something to do with the max amount of keys pressed but I have no clue how to get around it.
local UIS = game:GetService("UserInputService")
local function Click()
if UseBool then
UseBool = false
ReleaseAnimationTrack:Play()
ReleaseAnimationTrack:GetMarkerReachedSignal("Throw"):Connect(function()
if ThrowBool == true then
ThrowBool = false
game.ReplicatedStorage.RemoteEvents.Globalize:FireServer(viewModel.Handle.Position,camera.CFrame.LookVector * ThrowPower)
viewModel.Handle.Transparency = 1
end
end)
game.Players.LocalPlayer.PlayerGui.ProjectileGui.Ammo.CooldownBarBackground.CooldownBar.Size = UDim2.new(0,-4,1,-4)
Tween:Create(game.Players.LocalPlayer.PlayerGui.ProjectileGui.Ammo.CooldownBarBackground.CooldownBar,TweenInfo.new(Cooldown,Enum.EasingStyle.Linear),{Size = UDim2.new(1,-4,1,-4)}):Play()
wait(Cooldown)
ThrowBool = true
viewModel.Handle.Transparency = 0
EquipAnimationTrack:Play()
UseBool = true
end
end
if Mobile then
UIS.TouchTap:Connect(Click);
else
mouse.Button1Down:Connect(Click);
end
Any help would be appreciated.
1 Like
Ok so, I have no idea how you connected the function, so I am just going to assume you forgot about the parameters needed. First you have to add parameters for what keys you want to activate the function.
Inside the parenthesis of Click() there should be two parameters called Input and GameProcessedEvent. You don’t need to use GameProccessedEvent though, input is the important one.
example below
local function Click(input,GameProcessedEvent)
after this you want to add an if statement so you can filter out inputs for the either keycode or UserInputType. If you want it to detect mouse clicks only, use UserInputType, if you want key’s only then use KeyCode. Then after choosing either, you have to filter out for specific keys, this can be done by checking if it equals to a specific enum Item.
Example Below:
if input.KeyCode == Enum.KeyCode.--This should show a list of key's you can filter specifically to allow
or
if input.UserInputType == Enum.UserInputType. --This should show a list of things like the mouse
After adding this filter to your function, just put the rest of your code in this if statement. And after your function is ready, directly connect it to user input service
UIS.InputBegan:Connect(SaidFunction)
Make sure there are no parenthesis as well in the connection
Also I am NOT the best teacher out there, if you do not understand anything i just typed here, I recommend you read this
1 Like
I connected it with
local UseBool = true
if Mobile then
UIS.TouchTap:Connect(Click);
else
mouse.Button1Down:Connect(Click);
end
And it seems it was just a service bug.
But thanks for the help anyway!