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

How to fix this status if i press a button?

local Status1 = game.ReplicatedStorage:WaitForChild("WatingStatus")
local Status2 = game.ReplicatedStorage:FindFirstChild("WatingStatusUnder")

if script.Parent.MouseButton1Click:Connect(function() 
	Status1.Value = "Facility"
	Status2.Value = "By hokyboy"
end)

1 answer

✓ Accepted answer

You can't put a if statement next to an event. An event doesn't return something so you can't compare it which something, also an event is necessarily a value.

Instead an event is a piece of code that executes when a certain action is pressed. Your script fixed would be:

local Status1 = game.ReplicatedStorage:WaitForChild("WatingStatus")
local Status2 = game.ReplicatedStorage:FindFirstChild("WatingStatusUnder")

script.Parent.MouseButton1Click:Connect(function() 
    Status1.Value = "Facility"
    Status2.Value = "By hokyboy"
end)

let's use another example. The player added event. You cannot say this since you are comparing nil with a code block.

game.PlayersAdded:Connect(function() -- dont use a if statement
	
end)

You use if statements the other way. https://developer.roblox.com/articles/Conditional-Statements-in-Lua

Here's an article for events: https://developer.roblox.com/articles/events

2 comments

0

Lmao i just saw idk why i added it stupid me i guess

0

lol

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