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

Error? What am I doing wrong!?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

Okay, i'm testing out a new, but simple script.. And it won't work. In the output, it says : ServerScriptService.Script:6: 'then' expected near '=' .

Script:

local i = Instance.new("Hint", game.Workspace)
i.Name = "ModelTest"

game.Workspace.Part.Position = (game.Workspace.Part.Value = Value)

--[[
game.Workspace.Part.Postion = (game.Workspace.Part.Value = Value) - I inserted a Vertor3Value into the part from advanced objects (Just incase you where confused).
--]]

if game.Worksace.Part.Position = (game.Workspace.Part.Value = Value) then
    i.Text = "Part Moved"
end 

I've already tried adding another equal sign, like so:

game.Workspace.Part.Position = (game.Workspace.Part.Value == Value)

if game.WorksPace.Part.Position = (game.Workspace.Part.Value == Value) then
    i.Text = "Part Moved"
end 

But it still gives me an error. What am I doing wrong?

Thanks for your help.

-- Bloxer signing out!

0
Can you explain what you're *trying* to do? What you have written doesn't make any sense. BlueTaslem 18071 — 9y
0
When the part moves, a hint will pop up. User#9499 0 — 9y

4 answers

Log in to vote
0
Answered by 9 years ago

When you do one equal sign it means change the property but when you do two equal signs it's saying check if they are the same.

if game.WorksPace.Part.Position == (game.Workspace.Part.Value =  Value) then 

Also. (game.Workspace.Part.Value = Value) is very wrong you can't change a value while checking a value.

0
OH! User#9499 0 — 9y
0
Why the heck is this downvoted? Nickoakz 231 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

Always use 2 equal signs on if functions

"10 if game.Worksace.Part.Position = (game.Workspace.Part.Value = Value) then"

Log in to vote
0
Answered by 9 years ago

It is very hard to understand, but this is what I have so far:

local part = game.Workspace.Part
local Pos = Vector3.new(0,0,0)
Pos = part.Position
local i = Instance.new("Hint")
i.Parent = game.Workspace
i.Name = "ModelTest"
part.Changed:connect(function()
    if part.Position ~= Pos then
        Pos = part.Position
        i.Text = "Part has moved!"
    end
end)

Did this help?

Log in to vote
0
Answered by 9 years ago

Your interpretation of Lua syntax is incorrect.

I'm not sure what you're trying to do in the script, a little more context would be appreciated. I am still going to have my own go at this.

local i = Instance.new("Hint", game.Workspace)
i.Name = "ModelTest"

game.Workspace.Part.Position = game.Workspace.Part.Value.Value

if game.Workspace.Part.Position == game.Workspace.Part.Value.Value then
    i.Text = "Part Moved"
end 

Answer this question