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

How do I make a Text go 1 Up? [NOT SOLVED]

Asked by 10 years ago

I want a text to go up by 1 when you touch a brick. But I don't know how. Here's what I have:

local player = game.Players.LocalPlayer
function Touched()
    player.PlayerGui.ScreenGui.TextLabel.Text = +1
end

game.Players.LocalPlayer.Touched:connect(Touched)

1 answer

Log in to vote
0
Answered by
Tesouro 407 Moderation Voter
10 years ago

There are two errors in that script: touches is a number value and Text has to be a string value, you can't mix them and LocalPlayer is a player, you have to connect the body parts to the function. Fix:

local player = game.Players.LocalPlayer
local touches = 0

function Touched()
    touches = touches + 1
    player.PlayerGui.ScreenGui.TextLabel.Text = tostring(touches) -- now it's a string
end

 -- this will find the real body parts
for child, index in pairs (game.Players.LocalPlayer.Character:GetChildren()) do
    if child:IsA("Part") then
        child.Touched:connect(Touched)
    end
end
0
Doesn't work at all. DDDropTheBase 0 — 10y
0
You sure? I see not errors in that. No output? Tesouro 407 — 10y
0
Nothing in the output, it just doesn't work... DDDropTheBase 0 — 10y
0
Is the locla script where it should be? In a player's Backpack (can be indirectly, through a Tool or HopperBin), in a player's character moel or in a player's PlayerGui. Tesouro 407 — 10y
View all comments (2 more)
0
It's in a Part in Workspace. DDDropTheBase 0 — 10y
0
...oh god -> read this page, please: http://wiki.roblox.com/index.php?title=Local_script Tesouro 407 — 10y
Ad

Answer this question