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

Why does my if statement not work in local scripts?

i'm doing a game where you can use the CCTV cameras. I wanted to put this feature where if i switch to another camera it's gonna do a static effect and i was doing this by putting a variable that is gonna change depending in what camera i was using. However, it didn't work well. i tried to find a solution and i discovered that my if statements work on normal scripts but on local ones they don't. Can someone explain me this problem and how to solve it? Thank you.

v = 1

if v == 1 then
	print("bruh")
end

5 comments

0

Show us the script lol, they do work on local scripts

0

Also, where is the local script located? There are some services on wich local scripts don't run.

0

it's on the workspace

0

Show us the script

1

LocalScripts don't run in workspace, put them on StarterGui or StarterPlayerScripts.

1 answer

That prints "Bruh" and doesn't do it's job.

I don't see anything that could do that so... Here. Make the right arrow key named "Right" and the left arrow key "Left" Make sure you use the caps.

--In a local script inside the Right arrow key

local Static = (Run the static)()

script.Parent.MouseButton1Click:Connect(function()
	Static() --I assume that the function "Static" Runs the static.
end)


--In a local script inside the Left arrow key

local Static = (Run the static)()

script.Parent.MouseButton1Click:Connect(function()
	Static() --I assume that the function "Static" Runs the static.
end)

Lol I really did it

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