i have this script thats not working and i think it should work, any ideas why its not working?
local replicatedStorage = game:GetService("ReplicatedStorage")
local mapValue = replicatedStorage:WaitForChild("Map")
local function onValueChanged()
print("Hello World")
if mapValue.Value == "Baseplate" then
local currentmap = game.Workspace:WaitForChild("Map")
currentmap:Destroy()
local newmap = game.ServerStorage.Maps.Baseplate:Clone()
newmap.Parent = workspace
newmap.Name = "Map"
end
if mapValue.Value == "Crossroad" then
local currentmap = game.Workspace:WaitForChild("Map")
currentmap:Destroy()
local newmap = game.ServerStorage.Maps.Crossroad:Clone()
newmap.Parent = workspace
newmap.Name = "Map"
end
end
mapValue:GetPropertyChangedSignal("Value"):Connect(onValueChanged)
local replicatedStorage = game:GetService("ReplicatedStorage")
local mapValue = replicatedStorage:WaitForChild("Map")
local function onValueChanged()
print("running ok")
local OLDMap = workspace:FindFirstChild("Map")
if OLDMap then OLDMap:Destroy() end
local newMap
if mapValue.Value == "Baseplate" then
newMap = game.ServerStorage.Maps.Baseplate:Clone()
elseif mapValue.Value == "Crossroad" then
newMap = game.ServerStorage.Maps.Crossroad:Clone()
end
if newMap then
newMap.Parent = workspace
newMap.Name = "Map"
end
end
mapValue:GetPropertyChangedSignal("Value"):Connect(onValueChanged)
local replicatedStorage = game:GetService("ReplicatedStorage")
local mapValue = replicatedStorage:WaitForChild("Map")
local function onValueChanged()
print("running ok")
local OLDMap = workspace:FindFirstChild("Map")
if OLDMap then OLDMap:Destroy() end
local newMap
if mapValue.Value == "Baseplate" then
newMap = game.ServerStorage.Maps.Baseplate:Clone()
elseif mapValue.Value == "Crossroad" then
newMap = game.ServerStorage.Maps.Crossroad:Clone()
end
if newMap then
newMap.Parent = workspace
newMap.Name = "Map"
end
end
mapValue:GetPropertyChangedSignal("Value"):Connect(function()
onValueChanged()
end)
local replicatedStorage = game:GetService("ReplicatedStorage")
local mapValue = replicatedStorage:WaitForChild("Map")
mapValue:GetPropertyChangedSignal("Value"):Connect(function()
print("running ok")
local OLDMap = workspace:FindFirstChild("Map")
if OLDMap then OLDMap:Destroy() end
local newMap
if mapValue.Value == "Baseplate" then
newMap = game.ServerStorage.Maps.Baseplate:Clone()
elseif mapValue.Value == "Crossroad" then
newMap = game.ServerStorage.Maps.Crossroad:Clone()
end
if newMap then
newMap.Parent = workspace
newMap.Name = "Map"
end
end)
local replicatedStorage = game:GetService("ReplicatedStorage")
local mapValue = replicatedStorage:WaitForChild("Map")
local function ChangeMap()
print("running ok")
local OLDMap = workspace:FindFirstChild("Map")
if OLDMap then OLDMap:Destroy() end
local newMap
if mapValue.Value == "Baseplate" then
newMap = game.ServerStorage.Maps.Baseplate:Clone()
elseif mapValue.Value == "Crossroad" then
newMap = game.ServerStorage.Maps.Crossroad:Clone()
end
if newMap then
newMap.Parent = workspace
newMap.Name = "Map"
end
end
mapValue:GetPropertyChangedSignal("Value"):Connect(ChangeMap)
local replicatedStorage = game:GetService("ReplicatedStorage")
local mapValue = replicatedStorage:WaitForChild("Map")
mapValue:GetPropertyChangedSignal("Value"):Connect(function()
print("running ok")
local OLDMap = workspace:FindFirstChild("Map")
if OLDMap then OLDMap:Destroy() end
local newMap
if mapValue.Value == "Baseplate" then
newMap = game.ServerStorage.Maps.Baseplate:Clone()
elseif mapValue.Value == "Crossroad" then
newMap = game.ServerStorage.Maps.Crossroad:Clone()
end
if newMap then
newMap.Parent = workspace
newMap.Name = "Map"
end
end)
You were putting it inside a local function onValueChanged(), i said to try the script without putting it inside a function.