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

Error? What am I doing wrong!?

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!

2 comments

0

Can you explain what you're trying to do? What you have written doesn't make any sense.

0

When the part moves, a hint will pop up.

4 answers

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.

2 comments

0

OH!

0

Why the heck is this downvoted?

Always use 2 equal signs on if functions

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

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?

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 

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