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

Whats wrong with this basic script?

Asked by 10 years ago

I am working on a script so if the flags owner is a certain team then they will spawn on the flag Right now I am just testing, I will add the spawn part in later but why wont this work?

local Owner = game.Workspace.CapturableFlag.OfVanna.CurrentOwner.Value == " Olive " then
print("Sounds good")
end

2 answers

Log in to vote
1
Answered by
iaz3 190
10 years ago
local Owner = game.Workspace.CapturableFlag.OfVanna.CurrentOwner.Value == " Olive " then
print("Sounds good")
end

You have no if. You are trying to use then on a local variable.

If you wanted Owner to be true or false, then it would be

local Owner = game.Workspace.CapturableFlag.OfVanna.CurrentOwner.Value == " Olive " and true

The below should work for you

local Owner = game.Workspace.CapturableFlag.OfVanna.CurrentOwner -- if you put .Value here then if it changes, you won't know. you need to get in in real time, like below.
if Owner.Value == "Olive" then
    print("Sounds good")
end
0
Hmm, nope I tried it and it did not print anything, maybe this picture will help of my workspace http://gyazo.com/70133abce583e9add9a6c4fe077221e0 ggggyourface23 63 — 10y
0
You spelled Vanna wrong in your workspace. Simply rename it. SlickPwner 534 — 10y
0
I changed it on purpose, and was sure to fix the script, will try again ggggyourface23 63 — 10y
0
Does it still not work? iaz3 190 — 10y
0
You may have noticed i removed the trailing space from "Olive" so it wasent "Olive " That may be the problem. iaz3 190 — 10y
Ad
Log in to vote
-1
Answered by 10 years ago

Simple. You need to use the variable after you have declared it.

local Owner = game.Workspace.CapturableFlag.OfVanna.CurrentOwner.Value
if Owner == " Olive " then
print("Sounds good")
end

Or

local Owner = game.Workspace.CapturableFlag.OfVanna.CurrentOwner.Value
== " Olive "
if Olive then
print("Sounds good")
end

Answer this question