Hey there! BlackOrange here to help! (Check bottom .Changed actually works)
First of all, if Brick is a Part, I believe that you can't use .Changed on it. .Changed is normally for values such as IntValue, StringValue, NumberValue, ObjectValue and so on. So you might wanna change that part up.
Next, your code is very messy, so let's start off by making sure this is a ServerScript also known as Script
Now, Let's change your variables to local variables because right now you don't need global variables.
local respawntime = 10
local brick = script.Parent
local clone = brick:Clone()
local position = brick.Position
brick.Changed:connect(function()
local newposition = brick.Position
if position ~= newposition then
wait(respawntime)
brick:Destroy()
clone.Parent = game.Workspace
clone.Position = position
end
end
end)
Alright! But wait, the error says... Roblox Studio: Script:5: unexpected symbol near ')' Let's check out code. Most likely you have added an extra end!
local respawntime = 10
local brick = script.Parent
local clone = brick:Clone()
local position = brick.Position
brick.Changed:connect(function()
local newposition = brick.Position
if position ~= newposition then
wait(respawntime)
brick:Destroy()
clone.Parent = game.Workspace
clone.Position = position
end
end
end)
Alright, now delete the end so now we can move on. We now have to see what other problems are there. Firstly, when setting a position of a part, we use Vector3 or CFrame Let's use Vector3
local respawntime = 10
local brick = script.Parent
local clone = brick:Clone()
local position = brick.Position
brick.Changed:Connect(function(p)
local newposition = brick.Position
if p == "Position" then
wait(respawntime)
brick:Destroy()
clone.Parent = game.Workspace
clone.Position = Vector3.new(position)
end
end)
Alright almost done! ok now add p stands for property and check if property changed and change :connect to :Connect because :connect is deprecated. If you fix p everything should work out!
Links that might help you out:
http://wiki.roblox.com/index.php?title=API:Vector3
http://wiki.roblox.com/index.php/CFrame
http://wiki.roblox.com/index.php?title=API:Class/Instance/Changed -- Actually never mind, I just read it and it fires when any value changes sorry!
https://wiki.roblox.com/index.php?title=Changed
https://wiki.roblox.com/index.php?title=Deprecation
Best of luck my friend! Final code is the last one
1 comment
whoa, that is deeply detailed, totally adds up to my answer