What do you want to achieve? I made a simple script to enable a server script in the map after voting
What is the issue? It doesnt work and stays on the print("Script is starting")
What solutions have you tried so far? i tried changing things but doesn’t work
local RunService = game:GetService("RunService")
local mainMap = workspace.Map:FindFirstChildOfClass("Folder")
local canWarn = true
local function setMapServerScripts()
print("Script is starting")
if mainMap then
print("Script started")
local waypointsSetUp = mainMap:FindFirstChild("WaypointsSetUp")
if waypointsSetUp then
print("Script finished")
waypointsSetUp.Enabled = true
elseif canWarn then
warn("WaypointsSetUp not found inside map!")
canWarn = false
end
end
end
RunService.Heartbeat:Connect(setMapServerScripts)
I think it can’t find the mainMap Folder, it would run the rest if it did, but it doesn’t, maybe check if it exists and wait when it loads, otherwise Im not sure.
I also checked if game is running (after everything from vote is done map spawned etc) still doesn’t work, map is not nil but the script doesn’t find it, idk what’s happening, i need help
I can’t give a screenshot because i’m not in my pc right now but basically the map is in ServerStorage.Maps, when someone plays they need to vote for map and after that the choosen map from ServerStorage moves to workspace.Map which is why i use FindFirstChildOfClass(“Folder”) cuz different maps names
nope but somehow i fixed it by defining mainMap at the function, idk why this fixes it, i also changes alot of things
local RunService = game:GetService("RunService")
local votingGamemode = workspace.Info.GamemodeVoting
local mapFolder = workspace.Map or workspace:WaitForChild("Map")
local mainMap
local canWarn = true
local foundScript = false
local function setMapServerScripts()
-- print("Script is starting")
mainMap = mapFolder:FindFirstChildOfClass("Folder")
if mainMap then
-- print("Script started")
for _, descendant in pairs(mainMap:FindFirstChild("Scripts"):GetDescendants()) do
if descendant:IsA("Script") then
-- print("Script finished")
descendant.Enabled = true
foundScript = true
end
end
if not foundScript and canWarn then
warn("No server scripts found inside map!")
canWarn = false
end
return true
end
return false
end
votingGamemode:GetPropertyChangedSignal("Value"):Connect(function()
if votingGamemode.Value == true then
RunService.Heartbeat:Wait()
setMapServerScripts()
end
end)