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

How do i make a script that makes your head bigger?

Asked by
KelcriC -1
5 years ago

Here is my script right now

script.Parent.MouseClick:Connect(function(Player) local Character = Player.Character local Humanoid = Character:FindFirstChild('Humanoid') player = game:GetService("Players").LocalPlayer stats = player:findFirstChild("leaderstats") power = stats:findFirstChild("Power") power.Value = power.Value + 1

if Humanoid then
    local HS = Humanoid:FindFirstChild('HeadScale')
    local BDS = Humanoid:FindFirstChild('BodyDepthScale')
    local BWS = Humanoid:FindFirstChild('BodyWidthScale')
    local BHS = Humanoid:FindFirstChild('BodyHeightScale')



if HS and BDS and BWS and BHS then
    HS.Value = HS.Value + 0.03
    BDS.Value = BDS.Value + 0.015
    BWS.Value = BWS.Value + 0.015
    BHS.Value = BHS.Value + 0.015

local brick = script.Parent.Parent

for i = 1,2 do brick.CFrame = brick.CFrame*CFrame.new(0,-5,0) wait(15)

brick.CFrame = brick.CFrame*CFrame.new(0,5,0)

end end

end     
end)

it works in studio, but it never works in-game, can someone please help me.

0
LocalPlayer is nil on the server. You already have your player from MouseClick, no need for two player variables. User#19524 175 — 5y
0
So, what should i do for that? KelcriC -1 — 5y

1 answer

Log in to vote
0
Answered by
CjayPlyz 643 Moderation Voter
5 years ago
Edited 5 years ago

Your error is this : player = game:GetService("Players").LocalPlayer

first when using the MouseClick event it would give you the Player who clicked the button so you don't have to use LocalPlayer and LocalPlayer doesn't work with server scripts. And you also forgot to add local on some lines.

script.Parent.MouseClick:Connect(function(player)

    player.leaderstats.Power.Value = player.leaderstats.Power.Value + 1
    local character = player.Character
    local humanoid = character:FindFirstChild('humanoid')

    if Humanoid ~= nil then

     local HS = Humanoid:FindFirstChild('HeadScale')
     local BDS = Humanoid:FindFirstChild('BodyDepthScale')
     local BWS = Humanoid:FindFirstChild('BodyWidthScale')
     local BHS = Humanoid:FindFirstChild('BodyHeightScale')

        if HS and BDS and BWS and BHS ~= nil then

            HS.Value = HS.Value + 0.03
            BDS.Value = BDS.Value + 0.015
            BWS.Value = BWS.Value + 0.015
            BHS.Value = BHS.Value + 0.015

            local brick = script.Parent.Parent

            for i = 1,2 do brick.CFrame = brick.CFrame*CFrame.new(0,-5,0)

                wait(15)

                brick.CFrame = brick.CFrame*CFrame.new(0,5,0)

            end
        end 
    end
end)

Also i don't recommend putting the script in the click detector but it will work just fine.

Ad

Answer this question