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

How to resize my character Server-sided?

Asked by 3 years ago

I'm working on a game where you use tools to resize your character. They are fixed sizes, but the grow and shrink have the same problem: It only changes the character's size on the client. And I don't know how to make it server-sided. Please help! Here's the code for the small character tool:

script.Parent.Activated:Connect(function()
    local drinker = script.Parent.Parent.Humanoid
    drinker.BodyDepthScale.Value = 0.3
    drinker.BodyHeightScale.Value = 0.3
    drinker.BodyWidthScale.Value = 0.3
    drinker.HeadScale.Value = 0.3
    script.Parent.Parent.Humanoid.WalkSpeed = 25
    game.Workspace.Camera.FieldOfView = 20
end)

3 answers

Log in to vote
0
Answered by 3 years ago

Use RemoteEvents and they should be placed within a Folder in the tool. When the tool is activated, fire the RemoteEvent and change the size on the server.

Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Well, here you are using a Local Script so it will change it Client Sided. The simple solution is to fire a remoteevent to the Server.

-- Local Script
script.Parent.Activated:Connect(function()
        local rs = game:GetService("ReplicatedStorage")
    local re = rs:FindFirstChild("RemoteEvent") -- Change the name to your RemoteEvent

        local drinker = script.Parent.Parent.Humanoid

    re:FireServer(drinker)
end)

Now, we will set up the ServerScript and keep it in the ServerScriptService.

-- ServerScript
local rs = game:GetService("ReplicatedStorage")
local re = rs:FindFirstChild("RemoteEvent") -- Change the name to your RemoteEvent

local function Event(player, drinker) -- Creating a function
    drinker.BodyDepthScale.Value = 0.3
    drinker.BodyHeightScale.Value = 0.3
    drinker.BodyWidthScale.Value = 0.3
    drinker.HeadScale.Value = 0.3
    drinker.WalkSpeed = 25
    workspace.Camera.FieldOfView = 20
end

re.OnServerEvent:Connect(Event) -- Executes our function

Lemme know if it helps!

0
I did this, and I got an error: BodyDepthScale is not a valid member of Player "Players.Dothemariobowp9" Dothemariobowp9 24 — 3y
0
I edited the script, and it might help! The problem was I haven't added a variable to index the info passed by the event. BestCreativeBoy 1395 — 3y
Log in to vote
-1
Answered by 3 years ago

It is currently impossible to get the player's character from a LocalScript!

Answer this question