Hello! I've been practicing all night now and have been stuck on this one issue. When the player loads in I expect the function to run. Except that's not the case. Ive been trying for a few hours can seem to get a lead...
Code in question
player.CharacterAppearanceLoaded:Connect(function(character)
print("Joined")
local humanoid = character.Humanoid
humanoid:WaitForChild("BodyDepthScale").Value = .5 + (strength.Value / 250)
humanoid:WaitForChild("BodyHeightScale").Value = .5 + (strength.Value / 250)
humanoid:WaitForChild("BodyWidthScale").Value = .5 + (strength.Value / 250)
humanoid:WaitForChild("HeadScale").Value = .5 + (strength.Value / 250)
humanoid.WalkSpeed = 16 * (strength.Value / 250)
strength:GetPropertyChangedSignal("Value"):Connect(function()
humanoid:WaitForChild("BodyDepthScale").Value = .5 + (strength.Value / 250)
humanoid:WaitForChild("BodyHeightScale").Value = .5 + (strength.Value / 250)
humanoid:WaitForChild("BodyWidthScale").Value = .5 + (strength.Value / 250)
humanoid:WaitForChild("HeadScale").Value = .5 + (strength.Value / 250)
humanoid.WalkSpeed = 16 * (strength.Value / 250)
end)
end)
Full code
local serverStorage = game:GetService("ServerStorage") -- puts in here so explotiers cant access
local DataStore = game:GetService("DataStoreService")
local playerData = DataStore:GetDataStore("creatives201.0.1164")
local autosaveWait = 10
local function autoSave(player,data) -- gets player and data peramiters
local succes, err = pcall(function()
playerData:SetAsync(player.UserId,data)
end)
if succes then
return "data saved"
else
return "data not saved"
end
end
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 data = playerData:GetAsync(player.UserId) -- gets data store of player
if data ~= nil then
print("OldPlayer")
strength.Value = data["Strength"] -- sets players data to the data store
rebirths.Value = data["Rebirths"]
else -- if not old player sets up data values
print("new player setup")
local newData = { -- creates table for players
["Strength"] = 0,
["Rebirths"] = 0
}
playerData:SetAsync(player.UserId,newData) -- parents new data to data store
end
player.CharacterAppearanceLoaded:Connect(function(character)
print("Joined")
local humanoid = character.Humanoid
humanoid:WaitForChild("BodyDepthScale").Value = .5 + (strength.Value / 250)
humanoid:WaitForChild("BodyHeightScale").Value = .5 + (strength.Value / 250)
humanoid:WaitForChild("BodyWidthScale").Value = .5 + (strength.Value / 250)
humanoid:WaitForChild("HeadScale").Value = .5 + (strength.Value / 250)
humanoid.WalkSpeed = 16 * (strength.Value / 250)
strength:GetPropertyChangedSignal("Value"):Connect(function()
humanoid:WaitForChild("BodyDepthScale").Value = .5 + (strength.Value / 250)
humanoid:WaitForChild("BodyHeightScale").Value = .5 + (strength.Value / 250)
humanoid:WaitForChild("BodyWidthScale").Value = .5 + (strength.Value / 250)
humanoid:WaitForChild("HeadScale").Value = .5 + (strength.Value / 250)
humanoid.WalkSpeed = 16 * (strength.Value / 250)
end)
end)
while wait(autosaveWait)do
local data = { -- saves data
["Strength"] = strength.Value,
["Rebirths"] = rebirths.Value
}
local succes = autoSave(player,data)
print(succes)
end
end)
