This script should be updating a value over and over, then calling a function which reads the value in order to work. However, for some reason, Data keeps returning nil. The function also uses Data, however it is defined within the function itself. I tried making Data global which broke the function as it returned nil again. Thanks for any help.

16:44:09.543 - ServerScriptService.OutfitManager:55: attempt to index local 'Data' (a nil value)

function DescendList(player)
	local Data = player.Character:WaitForChild(player.Name.."'s Data")
	local WD = Data.WeldingAids:WaitForChild("WeldData")
	WD.Value = ("Chest")
	PerformWeld(player)
	wait(0.1)
	WD.Value = ("Torso")
	PerformWeld(player)
	wait(0.1)
	WD.Value = ("Pelvis")
	PerformWeld(player)
	wait(0.1)
	WD.Value = ("LeftArm")
	PerformWeld(player)
	wait(0.1)
	WD.Value = ("RightArm")
	PerformWeld(player)
	wait(0.1)
	WD.Value = ("LeftForearm")
	PerformWeld(player)
	wait(0.1)
	WD.Value = ("RightForearm")
	PerformWeld(player)
	wait(0.1)
	WD.Value = ("LeftElbow")
	PerformWeld(player)
	wait(0.1)
	WD.Value = ("RightElbow")
	PerformWeld(player)
	wait(0.1)
	WD.Value = ("LeftShoulder")
	PerformWeld(player)
	wait(0.1)
	WD.Value = ("RightShoulder")
	PerformWeld(player)
	wait(0.1)
	WD.Value = ("RightHand")
	PerformWeld(player)
	wait(0.1)
	WD.Value = ("LeftHand")
	PerformWeld(player)
	wait(0.1)
	
end

local event = game.ReplicatedStorage:WaitForChild("OutfitEvent") -- make sure the event in in ReplicatedStorage
event.OnServerEvent:connect(function(player) -- OnServerEvent automatically passes the player who fired it as the first argument.
	
DescendList(player)
print("Event Fired!")
    
end)

1 comment

0

FYI Everything in the script seems to work except DATA (Including the remote event)