Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

when I execute it no error comes in the output but my character size does not increase?

local serverStorage = game:GetService("ServerStorage") local DataStore = game:GetService("DataStoreService"):GetDataStore("PLayerSave3")

game.Players.PlayerAdded:Connect(function(player)

local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player

local strength = Instance.new("NumberValue")
strength.Name = "Strength"
strength.Parent = leaderstats	

local rebirths = Instance.new("IntValue")
rebirths.Name  = "Rebirths"
rebirths.Parent = leaderstats

local dataFolder = Instance.new("Folder")
dataFolder.Name = player.Name
dataFolder.Parent = serverStorage.RemoteData

local debounce = Instance.new("BoolValue")
debounce.Name = "Debounce"
debounce.Parent = dataFolder

local stregthData, rebirthsData

local success,errormessage = pcall(function()
	stregthData = DataStore:GetAsync("strength-"..player.UserId)
	rebirthsData = DataStore:GetAsync("rebirths-"..player.UserId)
end)

if success then
	if stregthData then
		strength.Value = stregthData
		rebirths.Value = rebirthsData
	end
end

player.CharacterAppearanceLoaded:Connect(function()
	local Char = player.CharacterAdded:Wait()
	Char:WaitForChild("BodyDepthScale").Value = 10 + (strength.Value / 250)
	Char:WaitForChild("BodyHeightScale").Value = 10 + (strength.Value / 250)
	Char:WaitForChild("BodyWidthScale").Value = 10 + (strength.Value / 250)
	Char:WaitForChild("HeadScale").Value = 10 + (strength.Value / 250)
	Char.WalkSpeed = 16 * (strength.Value / 250)
	
    strength:GetPropertyChangedSignal(function()
		Char:WaitForChild("BodyDepthScale").Value = 10 + (strength.Value / 250)
		Char:WaitForChild("BodyHeightScale").Value = 10 + (strength.Value / 250)
		Char:WaitForChild("BodyWidthScale").Value = 10 + (strength.Value / 250)
		Char:WaitForChild("HeadScale").Value = 10 + (strength.Value / 250)
		Char.WalkSpeed = 16 * (strength.Value / 250)
	end)
	
end)

end)

game.Players.PlayerRemoving:Connect(function(player) local success,errormessage = pcall(function() DataStore:SetAsync("strength-"..player.UserId,player.leaderstats.Strength.Value) DataStore:SetAsync("rebirths-"..player.UserId,player.leaderstats.Rebirths.Value) end) end)

1 answer

Maybe, JUST maybe, the WaitForChild()'s in lines 36 (or 37) to 47 is waiting for objects with specified names, thinking they are nonexistent even though they are.

Try using FindFirstChild()'s after the character loads.*. Using WaitForChild()'s will yield indefinitely waiting for a NEW object with the specified name, not for an existing part with said name.

Probably waiting for the character is enough on this matter. If you still are unsure, WaitForChild() accepts a second parameter: WaitForChild("name",timeout) - timeout so that it won't yield indefinitely.

Ex:

local Item = workspace:WaitForChild("something_i_guess", 5) -- Waits for child. If 5 seconds passed and there ain't no item named "something_i_guess", continue with the execution.

This discussion is preserved as it was. New answers, comments, and votes are closed.