#how to make a User Input Service on mobile

5 messages · Page 1 of 1 (latest)

past vessel
#

without context action service i am not redoing the script

#

i need it to be like this

#
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()

local light = char:WaitForChild("Head"):WaitForChild("HeadLight")
local Electricity = char:WaitForChild("Electricity")
local sound = game.Workspace["Switch In- Line Plastic Switch Clicks 3 (SFX)"]

local UIS = game:GetService("UserInputService")
local IsOn = false

UIS.InputBegan:Connect(function(inputobject)
    if inputobject.KeyCode == Enum.KeyCode.F then
        if IsOn == false then
            IsOn = true
            if Electricity.Value >= 1 then
                light.Enabled = true
                while task.wait(.1) do
                    Electricity.Value -= .02    
                    math.clamp(Electricity.Value, 0, 100)
                    if Electricity.Value <= 0 then
                        light.Enabled = false
                        IsOn = false
                    end
                    if IsOn == false then
                        break
                    end

                end
                
            end
        elseif IsOn == true then
            IsOn = false
            light.Enabled = false
        
        end
    
    end
end)

vast bear
past vessel
#

@vast bear i need it to work on mobile