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 4 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:

1script.Parent.Activated:Connect(function()
2    local drinker = script.Parent.Parent.Humanoid
3    drinker.BodyDepthScale.Value = 0.3
4    drinker.BodyHeightScale.Value = 0.3
5    drinker.BodyWidthScale.Value = 0.3
6    drinker.HeadScale.Value = 0.3
7    script.Parent.Parent.Humanoid.WalkSpeed = 25
8    game.Workspace.Camera.FieldOfView = 20
9end)

3 answers

Log in to vote
0
Answered by 4 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 4 years ago
Edited 4 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.

1-- Local Script
2script.Parent.Activated:Connect(function()
3        local rs = game:GetService("ReplicatedStorage")
4    local re = rs:FindFirstChild("RemoteEvent") -- Change the name to your RemoteEvent
5 
6        local drinker = script.Parent.Parent.Humanoid
7 
8    re:FireServer(drinker)
9end)

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

01-- ServerScript
02local rs = game:GetService("ReplicatedStorage")
03local re = rs:FindFirstChild("RemoteEvent") -- Change the name to your RemoteEvent
04 
05local function Event(player, drinker) -- Creating a function
06    drinker.BodyDepthScale.Value = 0.3
07    drinker.BodyHeightScale.Value = 0.3
08    drinker.BodyWidthScale.Value = 0.3
09    drinker.HeadScale.Value = 0.3
10    drinker.WalkSpeed = 25
11    workspace.Camera.FieldOfView = 20
12end
13 
14re.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 — 4y
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 — 4y
Log in to vote
-1
Answered by 4 years ago

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

Answer this question