Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

[SOLVED] How do I make mobile buttons for phones and tablets?

Asked by 4 years ago
Edited 4 years ago

I solved this by using a tutorial. But thanks to the comments for helping!

2 answers

Log in to vote
1
Answered by
Aztralzz 169
4 years ago

Put a screengui in startergui, then put a textbutton. For the leaderstats, put this code into ServerScriptService:

--leaderstats code
local function onPlayerJoin(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "nameyouwant"
    leaderstats.Parent = player

    -- Display an 'IntValue' on leaderboard
    local gold = Instance.new("IntValue")
    gold.Name = "yourname"
    gold.Value = 0
    gold.Parent = leaderstats
end

-- Run 'onPlayerJoin()' when the 'PlayerAdded' event fires
game.Players.PlayerAdded:Connect(onPlayerJoin)
-- code for button (same script in sss)
function clicked()
local point = 1
if game.StarterGui.ScreenGui.TextButton.Activated then
    game.StarterGui.ScreenGui.TextButton.Activated:Connect(function()
    gold.Value = gold.Value + point
end)
end
-- then loop the function to keep checking if player clicked the button
while true do
clicked()
print("works") -- not needed, but i do it to check if loop works
wait(0.5) -- if exhaust time is in output, add more wait time
end 
0
BTW: I didn't test this out. Aztralzz 169 — 4y
Ad
Log in to vote
1
Answered by 4 years ago
while true do
    wait()
    if script.Parent.Activated then
        local leaderboard = game.Players.LocalPlayer:FindFirstChild("leaderstats")
        local respect = leaderboard:FindFirstChild("Respect")
        respect.Value = respect.Value + 1
        local audio = workspace:FindFirstChild("RESPECT THE VETS")
        audio:Play()
        script.Parent.BackgroundTransparency = 0.5
        wait(1)
        script.Parent.BackgroundTransparency = 0
    end
end

my script

Answer this question