Event script doesn't complete

So I’m trying to create a task/mission system using events, and in this RemoteEventHandler script, in the AssignMissionEvent OnServer event function, it only works up to setting the Active Value true, it doesn’t print that it was set to true and any code I have after it doesn’t work or respond, and there’s no errors in the output coming from this script. I’ve tried multiple other ways such as WaitForChild() and printing messages for any errors.

local Services = {
	ReplicatedStorage = game:GetService("ReplicatedStorage"),
	ServerStorage = game:GetService("ServerStorage"),
	ReplicatedFirst = game:GetService("ReplicatedFirst"),
	Market = game:GetService("MarketplaceService"),
	DataService = game:GetService("DataStoreService"),
	UIS = game:GetService("UserInputService"),
	Players = game:GetService("Players"),
	Badge = game:GetService("BadgeService"),
}

local GameBadges = {
	Support = 2143451532,
	Robbery = 2143503899,
}

local Essential = {
	Filter = workspace:WaitForChild("Filter"),
	Npcs = workspace:WaitForChild("Filter"):WaitForChild("Npcs"),
}

local TaskRelated = Essential.Filter:WaitForChild("TaskRelated")
local TaskEssentials = {
	MailBoxes = TaskRelated:WaitForChild("Mailboxes_A"),
	UsedVal = TaskRelated:WaitForChild("Mailboxes_A"):WaitForChild("Used"),
}

Services.ReplicatedStorage.AssignMission.OnServerEvent:Connect(function(plr)
	print("AssignEvent has been activated.")
		local MissionValues = plr:FindFirstChild("MissionValues") or plr:WaitForChild("MissionValues")
		if MissionValues and MissionValues:FindFirstChild("Active") then
			plr.MissionValues.Active.Value = true
			print("Active set to true.")
		else
			print("MissionValues or Active value not found.")
		end
end)



Services.ReplicatedStorage:WaitForChild("UiEvents").ReturnManager.OnServerEvent:Connect(function(plr, manager)
	local Manager = Essential.Npcs:FindFirstChild(manager)
	if Manager then
		local name = Manager.Name
		Services.ReplicatedStorage.UiEvents.SendManager:FireClient(plr, name)
	end
end)
1 Like

Objects in starter player scripts don’t get replicated to the server. Try putting the value in player character.

A better solution would be to implement a player value table.

local playerTable = {}
local Activemissions = {}

game.Players.PlayerAdded:Connect(function(plr)
table.insert(playerTable, tostring(plr.UserId))
playerTable[tostring(plr.UserId)]["ActiveMissions"] = Activemissions

end)
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.