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

Whats wrong with my character size changing code?

Asked by
1_16o 0
2 years ago

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

Log in to vote
0
Answered by
imKirda 4491 Moderation Voter Community Moderator
2 years ago

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)
0
Its still not growing at all 1_16o 0 — 2y
0
do you have any errors on in View -> Output? imKirda 4491 — 2y
0
oh and by the way 1 is the default size if i am sure for these values, try using number like 2 imKirda 4491 — 2y
Ad

Answer this question