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

Why doesn't my script change my character's Walk Speed?

Hey. I want to change some of my character's properties such as the color and walk speed when I touch a part, but for some reason my script doesn't do it. But instead, if I wanna print something when I touch that part my script prints it. Any ideas why it doesn't work? Script:

local spawnerModel = game.Workspace:WaitForChild("SpawnerModel")
local spawner = spawnerModel:WaitForChild("Spawner")

spawner.Touched:Connect(function(person)
	local name = person.Name
	local playeroutofeveryone = game.Players:FindFirstChild(name)
	
	if playeroutofeveryone ~= nil then
		wait()
		local Armor = game.ReplicatedStorage:WaitForChild("Armor")
		local Armorholder = Instance.new("Model", person)
		Armorholder.Name = "Upgrade"
		person.Humanoid.BodyDepthScale.Value = script.DepthScale.Value
		person.Humanoid.BodyHeightScale.Value = script.HeightScale.Value
		person.Humanoid.BodyWidthScale.Value = script.WidthScale.Value
		person.Humanoid.HeadScale.Value = script.HeadScale.Value
		person.Shirt.ShirtTemplate = script.Shirt.Value
		person.Pants.PantsTemplate = script.Pants.Value
		
		local BodyColors = person:WaitForChild("Body Colors")
		BodyColors.HeadColor = BrickColor.new("Black")
		BodyColors.LeftArmColor = BrickColor.new("Black")
		BodyColors.LeftLegColor = BrickColor.new("Black")
		BodyColors.RightArmColor = BrickColor.new("Black")
		BodyColors.RightLegColor = BrickColor.new("Black")
		BodyColors.TorsoColor = BrickColor.new("Black")
		
		person.Humanoid.WalkSpeed = 20
		person.Humanoid.MaxHealth = 1000
		person.Humanoid.JumpPower = 100
	end
end)

6 comments

1

You are probably referencing a part not the player humanoid.

0

Also you should always post error logs when problems like that occur (if you can).

0

^, "person" is actually a part. You should rename that to part. Then say that person = part.Parent

0

do person.Parent since the Touched might touch the person's legs.

0

There is no part called bruceywayne :\ and there are no errors shown in Output.

0

Thanks ScrewDeath! You're solution fixed the problem! Thanks to everyone else aswell :D

1 answer

✓ Accepted answer

:D You need use like that!:

local spawnerModel = workspace:WaitForChild("SpawnerModel")
local spawner = spawnerModel:WaitForChild("Spawner")

local Players = game:GetService("Players")
spawner.Touched:Connect(function(hit)
	if Players:GetPlayerFromCharacter(hit.Parent) then
		local Player = Players[hit.Parent.Name]
		--etc..
	end
end)

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