Im making a minimap.
I have a server script in the workspace that detects when a player has spawned, which fires a remote event to all clients.
This remote event clones a 2x2 frame(Called mapMarker) with a script; the mapMarker is parented to the minimap.
The script monitors the players position and places the mapMarker in the correct location on the minimap.
when the player dies, the mapMarker is destroyed so another can be created.
I should note that the minimap works great, besides this:
TLDR;
when the player respawns, The Remote event fires again, and the mapMarker is once more cloned, a simple print tells me its values are being recorded, and then another print tells me that the mapMarker is parented to the minimap.
local repStorage = game:GetService("ReplicatedStorage");
local remote = repStorage.Remotes:WaitForChild("Remote_CreateMapMarker");
remote.OnClientEvent:connect(function(player)
local mapObj = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").Interface.Screens.MapScreen.MapMarker:Clone();
mapObj.MarkerScript.Target.Value = player;
mapObj.Visible = true;
mapObj.Parent = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").Interface.Screens.MapScreen.ScrollingFrame;
print (mapObj.Parent); -- PRINTS CORRECT PARENT EVERY TIME
mapObj.MarkerScript.Disabled = false;
if player.Name ~= game.Players.LocalPlayer.Name then
mapObj.BackgroundColor3 = Color3.fromRGB(255,255,0);
end
end)
The script within the mapMarker however, returns the mapMarkers parent as nil. The target prints fine. the while loop runs. but the mapMarker is no longer parented to minimap.
local mapMarker = script.Parent;
local player = game.Players.LocalPlayer;
local target = script:FindFirstChild("Target").Value;
target = game.Workspace:WaitForChild(target.Name);
local OffsetXValue = 508;
local OffsetYValue = 514;
print (target.Name); -- returns the players name
print (mapMarker.Parent); -- RETURNS NIL
local humanoid = target:WaitForChild("Humanoid");
while humanoid.Health > 0 do
if target:FindFirstChild("HumanoidRootPart") ~= nil then
--..
-- Some gui positioning code. (Irrelivant, and removed to save space)
--..
end
wait(0.1);
-- This was my attempt at parenting it, but it threw an error
-- if mapMarker.Parent ~= game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").Interface.Screens.MapScreen.ScrollingFrame then
-- mapMarker.Parent = game.Players.LocalPlayer.PlayerGui:WaitForChild("MainGui").Interface.Screens.MapScreen.ScrollingFrame;
-- print (mapMarker.Parent);
-- end
end
mapMarker:Destroy();
After several attempts at fixing this, i thought I would just parent it using the while loop I already had inside the script, but that throws and error:
23:34:12.264 - The Parent property of MapMarker is locked, current parent: NULL, new parent ScrollingFrame
The mapmarker is nowhere in the explorer (I did a search) but the while loop is running. It just wont parent.
Any thoughts? Thanks for taking the time to read this :)

1 comment
One of my thoughts is your over usage of semi-colons has reduced potential helpers by roughly 66.6%. satan