local Players = game:GetService("Players") function onPlayerAdded(player) local plr = game:GetService([[Players]]).LocalPlayer local Character = plr.Character local Humanoid = Character:FindFirstChild('Humanoid') if Humanoid then local BDS = Humanoid:FindFirstChild('BodyDepthScale') local BHS = Humanoid:FindFirstChild('BodyWidthScale') if BDS and BHS then BDS.Value = .001 BHS.Value = .001 print("Hey boo") end end end --When a player joins, call the onPlayerAdded function Players.PlayerAdded:connect(onPlayerAdded)
There's no need to use multi-line string syntax, quotes are fine, and you already fetched the service before with a variable. The server has no concept of a local player, because the local player is the Player
instance of the client.
The player's Player.Character
will be nil
when the character does not exist. Use the Player.CharacterAdded
event to get around this.
game.Players.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function(Character) -- Code end) end)
RBXScriptSignal:connect()
with a lowercase c is deprecated, switch to RBXScriptSignal:Connect()
with a capital C.
The output window is your friend! When I run your script I get the error Script:6: attempt to index local 'Character' (a nil value)
in output, so this tells us it doesn't know what "Character" is.
We can fix this by adding "or plr.CharacterAdded:Wait()
"
What this does is pretty simple, the first half (before the "or") tries to set the variable to the character linked with the player, but if it doesn't exist, it moves on to the second half (after the "or").
The second part, "plr.CharacterAdded:Wait()
", makes the script wait until a character is added, then continues on.
local Players = game:GetService("Players") function onPlayerAdded(player) local Character = player.Character or player.ChildAdded:Wait() local Humanoid = Character:FindFirstChild('Humanoid') if Humanoid then local BDS = Humanoid:FindFirstChild('BodyDepthScale') local BHS = Humanoid:FindFirstChild('BodyWidthScale') if BDS and BHS then BDS.Value = .001 BHS.Value = .001 print("Hey boo") end end end --When a player joins, call the onPlayerAdded function Players.PlayerAdded:connect(onPlayerAdded)
I also made 2 more changes:
First I changed line 4, not only was this variable unnecessary since the function has a "player" variable linked to it, but also you were trying to get LocalPlayer from a server script, which is not possible.
And the final thing is you were using "connect" instead of "Connect". "connect" is deprecated, which means you shouldn't use it anymore for new work.