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

Whats wrong with my character size changing code?

Hello, I have been using this tutorial (my code isn't a complete copy bc of what I need in my game) but my code so far isn't working, here is what I have done so far:

local frame = script.Parent

local grow = frame.grow
local shrink = frame.shrink
local size = 1

local player = game.Players.LocalPlayer


grow.MouseButton1Click:Connect (function()
	
	player.Character.Humanoid.HeadScale.Value = size
	player.Character.Humanoid.BodyWidthScale.Value = size
	player.Character.Humanoid.BodyHeightScale.Value = size
	player.Character.Humanoid.BodyDepthScale.Value = size
	
end)

1 answer

If you do this in LocalScript, changes won't be seen on anyone else's screen except yours, to fix this you can use remote events, these are instances that let you send messages to Roblox server to show something to everybody:

LocalScript

local frame = script.Parent

local grow = frame.grow
local shrink = frame.shrink

local size = 1

local resizeCharacter = game.ReplicatedStorage.ResizeCharacter

grow.MouseButton1Click:Connect(function()
	-- Send signal to server with "size" value

	-- Note that exploiters can put any value here so for security reasons
	-- it's good to save values on server and only send "codes" where
	-- each code corresponds to its value or just prevent the value
	-- from being bigger or lower than some value on server
	resizeCharacter:FireServer(size)
end)

ServerScriptService.CharacterResizer (Script)

-- You can create this remote event in studio, but kirda can't
local resizeCharacter = Instance.new("RemoteEvent")
resizeCharacter.Name = "ResizeCharacter"
resizeCharacter.Parent = game.ReplicatedStorage

-- When some noob sends signal though remote event, this function executes
resizeCharacter.OnServerEvent:Connect(function(player, size)
	-- Simple exploiter protection, if someone tries to resize himself
	-- to something bigger than 10 or smaller than 0 it's possible
	-- that he is cheater, if you want to do that intentionally, you should
	-- change these magic numbers
	if size > 10 or size < 0 then
		return
	end

	player.Character.Humanoid.HeadScale.Value = size
	player.Character.Humanoid.BodyWidthScale.Value = size
	player.Character.Humanoid.BodyHeightScale.Value = size
	player.Character.Humanoid.BodyDepthScale.Value = size
end)

3 comments

0

Its still not growing at all

0

do you have any errors on in View -> Output?

0

oh and by the way 1 is the default size if i am sure for these values, try using number like 2

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