Hi I am learning to code, This script wont execute
local part = script.Parent
local function disappear ()
part.CanCollide = false
end
local function appear ()
part.CanCollide = true
end
script.Parent = disappear()
end
It shows Synatx Error Expected got ‘end’ This synatx errors shows at the last end statement , i am trying to change part properties from script but it wont work please help
You have an extra end. Remove the last end that’s after the script.Parent line.
I don’t understand what’s this line supposed to do:
You have a function that makes the part invisible, but it returns nothing so you’re basically destroying the part. (Setting the parent to nil).
You’re basically doing this:
script.Parent = nil
If you want to run the functions just write them normally, no need for script.Parent.
Like this:
local part = script.Parent
local function disappear()
part.CanCollide = false
end
local function appear()
part.CanCollide = true
end
disappear() --Part.CanCollide set to false
wait(3) --Just a short delay for testing
appear() --Part.CanCollide set to true
Few other notes:
The BasePart.CanCollide property won’t make it disappear or appear (unless part falls), it’ll just determine whether things can move through it (collide with it) or not).
I suggest you to use BasePart.Transparency instead.
Suggest you to read about indentation, it’ll make code more readable.