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)
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.
-- 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!
It is currently impossible to get the player's character from a LocalScript!