Script not Working

Im trying to have a Block appear when LePa.CanCollide == true. its not working, heres the script
‘’'local Number = script
local gui = Number.Ending

local LePa = game.Workspace.BrokenParts.LeftPanel
local R1 = game.Workspace.BrokenParts.Rest1
local EG = game.Workspace.BrokenParts.Engine
local RP2 = game.Workspace.BrokenParts.RightPanel2
local SB = game.Workspace.BrokenParts.SeatBack
local OW = game.Workspace.BrokenParts.OverWindow
local RP = game.Workspace.BrokenParts.RightPanel
local CP = game.Workspace.BrokenParts.Computer
local LP2 = game.Workspace.BrokenParts.LeftPanel2
local R2 = game.Workspace.BrokenParts.Rest2
local RW = game.Workspace.BrokenParts.RightWing
local TW = game.Workspace.BrokenParts.TopWing

if LePa.CanCollide == true then
game.Workspace.TEST.Transparency = 0

end’‘’

whats wrong with it? It is a script in Workspace

It could be not working because it’s checking if CanCollide is true before it actually changes. So it could be that when you set it to be true in another script/localscript, it’s doing it after this script checks, thus showing up as false.

The solution in that case would be to use GetPropertyChangedSignal for CanCollide. Here’s, I believe, what you’d want to do:

local Number = script
local gui = Number.Ending

local LePa = game.Workspace.BrokenParts.LeftPanel
local R1 = game.Workspace.BrokenParts.Rest1
local EG = game.Workspace.BrokenParts.Engine
local RP2 = game.Workspace.BrokenParts.RightPanel2
local SB = game.Workspace.BrokenParts.SeatBack
local OW = game.Workspace.BrokenParts.OverWindow
local RP = game.Workspace.BrokenParts.RightPanel
local CP = game.Workspace.BrokenParts.Computer
local LP2 = game.Workspace.BrokenParts.LeftPanel2
local R2 = game.Workspace.BrokenParts.Rest2
local RW = game.Workspace.BrokenParts.RightWing
local TW = game.Workspace.BrokenParts.TopWing

LePa:GetPropertyChangedSignal("CanCollide"):Connect(function()
    if LePa.CanCollide == true then
        game.Workspace.TEST.Transparency = 0
    end
end)

Let me know how it goes!

EDIT: Extra tip. When you format your code on the devforum, don’t use ', use `. It is confusing and it’s not a commonly used key, but for most keyboards the button is right below “esc” and above “tab”.

Also, here’s the Roblox Developer API link to learn more about GetPropertyChangedSignal: Instance | Documentation - Roblox Creator Hub

ok the script did not work, maybe its were i have to put the script, RN its just a script in Workspace

is this script inside workspace or what

its just in workspace, nothing else

oh yeah scripts in workspace dont run unless its a part with a touched event

where would you put the script?

inside a part you want the character to touch

put it in serverscriptservice and just loop through every part and make a touched event and code inside it but i just recommend you put it in serverscriptservice

ok ill try it and let you know

Its not working, this is the one part of my game thats not working lol

collection service and loop through them with a touched event

do you want the script to activate once you touch a part?

Im sorry, im new at this. I dont understand

no, I need it when a part touches the other part which makes that part visible

srry if you dont understand

Could you please clarify further.

That is not true. Scripts within workspace are not limited to running only touched events. Op, the second post should work fine, if that is what you want.

1 Like

I am working on a game based on an alien planet. The main point of the game is to rebuild your ship and escape. I need the ship to be able to be rebuilt in any order, but any script it try is not working. Here is a video

robloxapp-20200906-1738440.wmv (2.4 MB)

local Part = workspace.Part
local OtherPart = workspace.OtherPart
local Swap = false
local PlayersOnly = false

if not Swap then
	Connection = Part.Touched:Connect(function(hit)
		if PlayersOnly then
			local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
			if Player ~= nil then
				Connection:Disconnect()
				OtherPart.Transparency = 0
				Part.CanCollide = false
				Part.Transparency = 1
			end
		else
			Connection:Disconnect()
			OtherPart.Transparency = 0
			Part.CanCollide = false
			Part.Transparency = 1
		end
	end)
else
	Connection = OtherPart.Touched:Connect(function(hit)
		if PlayersOnly then
			local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
			if Player ~= nil then
				Connection:Disconnect()
				Part.Transparency = 0
				OtherPart.CanCollide = false
				OtherPart.Transparency = 1
			end
		else
			Connection:Disconnect()
			Part.Transparency = 0
			OtherPart.CanCollide = false
			OtherPart.Transparency = 1
		end
	end)
end

Not sure if this is what you are trying to do

So, is LePa.CanCollide = true by the time the script runs? Or is there a seperate script/localscript changing it to be true at some point?

1 Like