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

Why does my if statement not work in local scripts?

Asked by 4 years ago
Edited 4 years ago

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

0
Show us the script lol, they do work on local scripts User#32819 0 — 4y
0
Also, where is the local script located? There are some services on wich local scripts don't run. User#32819 0 — 4y
0
it's on the workspace mattking71 29 — 4y
0
Show us the script Azure_Kite 885 — 4y
1
LocalScripts don't run in workspace, put them on StarterGui or StarterPlayerScripts. User#32819 0 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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

Ad

Answer this question