Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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"

1 comment

0

im actually dumb but thank you so much man bless u

This discussion is preserved as it was. New answers, comments, and votes are closed.