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:
1 | script.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 |
9 | end ) |
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.
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 |
2 | script.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) |
9 | end ) |
Now, we will set up the ServerScript and keep it in the ServerScriptService.
01 | -- ServerScript |
02 | local rs = game:GetService( "ReplicatedStorage" ) |
03 | local re = rs:FindFirstChild( "RemoteEvent" ) -- Change the name to your RemoteEvent |
04 |
05 | local 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 |
12 | end |
13 |
14 | re.OnServerEvent:Connect(Event) -- Executes our function |
Lemme know if it helps!
It is currently impossible to get the player's character from a LocalScript!