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

My lives script for my spinner doesn't work. Can someone help? (THIS QUESTION IS ANSWERED)

Asked by 3 years ago
Edited 3 years ago

So, made a spinner script and obv did all the other things to make it spin. But I wanted to add some lives and I've coded it like this but for some reason it doesn't work.

--Variables--
local Brick = script.Parent
--End--

--Code--
local function PlayerTouched(Part)
    local Parent = Part.Parent
    if game.Players:GetPlayerFromCharacter(Parent) then
        Parent.Humanoid.Health = 90
        if workspace.spinner.Lives.BillboardGui.TextLabel.Text = "Lives: 10" then
            workspace.spinner.Lives.BillboardGui.TextLabel.Text = "Lives: 9"
        end
    end
end

Brick.Touched:connect(PlayerTouched)
--End--

I haven't completed the code just tested if the code worked with just that but it didn't which is why I'm posting. Does anyone know how to fix this? Also, I'm new at lua so please try to keep it simple

1 answer

Log in to vote
0
Answered by
kylaex 17
3 years ago

When using the if statement you need to use a relational operator, so this can be easily fixed by just making line 10 into:

 if workspace.spinner.Lives.BillboardGui.TextLabel.Text == "Lives: 10"
0
im actually dumb but thank you so much man bless u CraftyAlphaMan 11 — 3y
Ad

Answer this question