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

Expected Then got if can you help?

so i was testing the fgame and got and error saying >17:50:11.426 - Workspace.Door1.Script:8: Expected 'then' when parsing if statement, got 'if' heres my code:

Heres my code:

local rc = 100

local debounce = true
script.Parent.Touched(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		if player.leaderstats.Bucks.Value >= rc
			   if debounce then
				debounce = false
				script.Parent.Transparency 0.7
				script.Parent.CanCollide = false
				if rc.Value <= rc then
				script.Parent.Transparency = 0.5
				script.Parent.CanCollide = true
			end
		end
	end
end)

2 comments

0

put in code block pls

0

fixed the code sorry

1 answer

✓ Accepted answer
local rc = 100

local debounce = true
script.Parent.Touched(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if player.leaderstats.Bucks.Value >= rc --then is missing here
               if debounce then
                debounce = false
                script.Parent.Transparency 0.7
                script.Parent.CanCollide = false
                if rc.Value <= rc then
                script.Parent.Transparency = 0.5
                script.Parent.CanCollide = true
            end
        end
    end
end)

You missed a then, and when it said 'got if', there was another if then statement after it. Hope this maybe solves it?

edited to be organized properly because you edited after i posted answer xd

3 comments

0

also dont forget a 4th end because there are 4 'if then' statements

0

uhh its not working

0

nvm

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