Quick fix short code. I am a beginner

Hello there This should be a quick easy fix as I am new to lua and I am learning.
So I have a bool value and when it switched to ture I want the map to go out of serverstorage and into workspace I have tried the code below and changed it but to no appeal it worked.

local Map1 = game.ServerStorage.Map1
local stat = game.ReplicatedStorage.Main.Status

stat.Changed:Connect(function(Value)
	if stat.Value == true then
		Map1.Parent = game.Workspace
		print(Value)
	end
end)

If more details needed please let me know, thanks!

1 Like

A local script cannot index the contents of Server Storage, make sure this is a Server Script.

1 Like

It is a script not local and placed in serverscript service.

Use GetPropertyChangedSignal instead. Also, are there any errors and what do you use to change the bool value?

I’m assuming that stat is a bool value.

1 Like

Yes, It is a bool value. And I will try that.

Like this?

stat.GetpropertyChangedSignal:Connect(function(Value)
	if stat.Value == true then
		Map1.Parent = game.Workspace
		print(Value)
	end
end)

stat:GetPropertyChangedSignal("Value"):Connect(function()
	if stat.Value == true then
		Map1.Parent = game.Workspace
		print(stat.Value)
	end
end)

you need to put a : before the statement

2 Likes

No, more like stat:GetPropertyChangedSignal("Value").

You can keep the Changed event. Value objects have an altered Changed event that only detects when it’s value property changes, so no need for GetPropertyChangedSignal.

also instead of parenting the Map in workpace, I would clone it then parent it under workspace.

local Map = Map1:Clone()
Map.Parent = game.Workspace
1 Like