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

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

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.

2 comments

0

LocalPlayer is nil on the server. You already have your player from MouseClick, no need for two player variables.

0

So, what should i do for that?

1 answer

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.

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