Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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)
1
You are probably referencing a part not the player humanoid. AlphaGamer150 101 — 5y
0
Also you should always post error logs when problems like that occur (if you can). AlphaGamer150 101 — 5y
0
^, "person" is actually a part. You should rename that to part. Then say that person = part.Parent ScrewDeath 153 — 5y
0
do person.Parent since the Touched might touch the person's legs. User#22219 20 — 5y
View all comments (2 more)
0
There is no part called bruceywayne :\ and there are no errors shown in Output. bruceywayne 35 — 5y
0
Thanks ScrewDeath! You're solution fixed the problem! Thanks to everyone else aswell :D bruceywayne 35 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

: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)
Ad

Answer this question