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

This size change script isnt working when the random number is 2?

Asked by 2 years ago

I am trying to make a script where something random happens. On the first part the game has a chance of making the baseplate ice and slippery but for the second part im trying to make it so the character increases in size but it does not seem to work. This is my script:

local baseplate = workspace.Baseplate
local originalProps = baseplate.CustomPhysicalProperties
local RandomNumber = math.random (2,2)



if RandomNumber == 1 then
    print("1")
    game.Workspace.Baseplate.Material = "Ice"
    baseplate.CustomPhysicalProperties = PhysicalProperties.new(
    originalProps.Density,
    0, -- Friction,
    originalProps.Elasticity,
    100, -- Friction weight
    originalProps.ElasticityWeight)
    game.Workspace.Baseplate.CustomPhysicalProperties.FrictionWeight = 100

end

if RandomNumber == 2 then
    print ("2")
    local Character = game.Players
    local Humanoid = Character.PlayerAdded:FindFirstChild("Humanoid")
    for i,Child in pairs (Humanoid:GetChildren()) do
        if Child.Name == 'BodyDepthScale' then
            Child.Value = 1         
        elseif Child.Name == 'HeadScale' then
            Child.Value = 1
        elseif Child.Name == 'BodyHeightScale' then
            Child.Value = 1
        elseif Child.Name == 'BodyWidthScale' then
            Child.Value = 1
        end
    end
end

2 answers

Log in to vote
0
Answered by 2 years ago

Your error can be found in line 22. You are trying to get the Humanoid from the Player not the character. Humanoid is a child of the character.

Ad
Log in to vote
0
Answered by
enes223 327 Moderation Voter
2 years ago

hey you! have you ever heard of enes? if you are in trouble, better call enes!

Answer this question