Hello again. I'm having trouble with a RemoteEvent. It involves a LocalScript inside an ImageButton and a server-side script inside ServerScriptService. The two scripts work perfectly in Studio's Play mode, but not in-game. Here's the two scripts.
Local script:
local storage = game:GetService("ReplicatedStorage") local remote = storage.ShrinkRemote local plr = game.Players.LocalPlayer local button = script.Parent local value = plr.PlayerGui.ScreenGui.ScaleValue button.MouseButton1Click:Connect(function() if button.Image == "rbxassetid://2310019779" then if value.Value == false then print("Shrink button fire!") value.Value = true remote:FireServer() end end end)
And the server script:
local storage = game:GetService("ReplicatedStorage") local remote = storage.ShrinkRemote remote.OnServerEvent:connect(function(plr) local chr = plr.Character local size = plr.PlayerGui.ScreenGui.SizeValue print("Shrink phase 2 reached!") for i=0,50 do size.Value = size.Value - 0.0137254902 chr.Humanoid.BodyDepthScale.Value = size.Value chr.Humanoid.BodyHeightScale.Value = size.Value chr.Humanoid.BodyWidthScale.Value = size.Value chr.Humanoid.HeadScale.Value = size.Value chr.Humanoid.WalkSpeed = chr.Humanoid.WalkSpeed - 0.196078431 chr.Humanoid.JumpPower = chr.Humanoid.JumpPower - 0.392156863 wait(0.005) end print("Shrinking was a success!") end)
By looking at the printed text in the Developer Console, I can deduce that the LocalScript did in fact fire the RemoteEvent, but for whatever reason, the server-side script is not receiving it. The last print I get when pressing the button is "Shrink button fire!". Any help would be greatly appreciated. Thank you.
PlayerGui
's descendants. In a real game, the server does not see its descendants. It just acknowledges the fact that it exists but that's about it. You don't need any RemoteEvent
s at all, even for changing the WalkSpeed
as any humanoid changes are replicated to the server.local client = game:GetService("Players").LocalPlayer local chr = client.Character or client.CharacterAdded:Wait() local size = client.PlayerGui.ScreenGui.SizeValue local value = client.PlayerGui.ScreenGui.ScaleValue script.Parent.Activated:Connect(function() print("Shrink phase 2 reached!") if button.Image == "rbxassetid://2310019779" then if not value.Value then print("Shrink button fire!") value.Value = true remote:FireServer() end end for i=0,50 do size.Value = size.Value - 0.0137254902 chr.Humanoid.BodyDepthScale.Value = size.Value chr.Humanoid.BodyHeightScale.Value = size.Value chr.Humanoid.BodyWidthScale.Value = size.Value chr.Humanoid.HeadScale.Value = size.Value chr.Humanoid.WalkSpeed = chr.Humanoid.WalkSpeed - 0.196078431 chr.Humanoid.JumpPower = chr.Humanoid.JumpPower - 0.392156863 wait(0.005) end print("Shrinking was a success!") end)
if
statements but it was just a simple fix. And remember, if you're working with GUIs, do it on the client!