game.ReplicatedStorage.SizeUp.OnServerEvent:Connect(function(plr)
local UserInputService = game:GetService("UserInputService")
local LocalPlayer = plr
local button = game.StarterGui.SizeUp.SizeUpB
-- Function to check if a tool is being equipped
local function isToolEquipped()
local character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
for _, child in pairs(character:GetDescendants()) do
if child.ClassName == "Tool" then
return true
end
end
return false
end
-- Function to run when button is clicked
local function onButtonClicked()
if not isToolEquipped() then
-- Run the rest of the script
local character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local currentScale = character:GetScale()
if currentScale == 1.0 then
character:ScaleTo(1.5)
elseif currentScale == 0.5 then
character:ScaleTo(1.0)
end
else
-- Do nothing if a tool is being equipped
end
end
button.MouseButton1Click:Connect(onButtonClicked)
end)
and basically what its supposed to do is after the player clicks a button on their screen it sends a message to the remote event then this script fires and when i put print statements they print but the character wont size up like its supposed to.
any ideas on what might be wrong?
So the problem I am seeing right now is that you have it so when you press a button you size up, the problem with this is that the button is in StarterGui, a common misconception, the UI the players see is not in StarterGui, its in PlayerGui.
Along with that what I would recommend is instead of detecting when the button is pressed on the server, check when it happens on the client, then send the remote event to the server telling it to size up the player, this might be better for performance, maybe, maybe not idk. But its good practice nonetheless I think.
But yes the problem right now is that the button you are trying to see is clicked, is never clicked, cause the actual button is in the players PlayerGui.
i have another script that sizes it down but its just a local script ill go turn it into a server script with a remote function and that should be the fix i just made the mistake of making almost everything local
that seemed to be the fix but now it when it reaches either 1.5 or 0.5 it never goes to 1.0
both scripts are the same expect the remote event name and this part
if currentScale == 1.0 then
character:ScaleTo(0.5)
elseif currentScale == 1.5 then
character:ScaleTo(1.0)
end
im sorry about the endless amount of issues im not very good at scripting
instead of the if statements, not sure this would solve the issue, but its much cleaner, you can do this:
-- This is for removing scale
local NewScale = math.clamp(currentScale - 0.5, 0.5, 1.5)
character:ScaleTo(NewScale)
-- This is for adding scale
local NewScale = math.clamp(currentScale + 0.5, 0.5, 1.5)
character:ScaleTo(NewScale)
this is the issue it still just keeps going from 0.5 to 1.5 after working once im not sure why its not working now because when i had them in just the local script it was working
local UserInputService = game:GetService("UserInputService")
local button = plr.PlayerGui.SizeDown.SizeDownB
-- Function to check if a tool is being equipped
local function isToolEquipped()
local character = plr.Character or plr.CharacterAdded:Wait()
for _, child in pairs(character:GetDescendants()) do
if child.ClassName == "Tool" then
return true
end
end
return false
end
-- Function to run when button is clicked
local function onButtonClicked()
if not isToolEquipped() then
-- Run the rest of the script
local character = plr.Character or plr.CharacterAdded:Wait()
local currentScale = character:GetScale()
-- This is for removing scale
if currentScale == 1.0 then
character:ScaleTo(0.5)
elseif currentScale == 1.5 then
character:ScaleTo(1.0)
end
else
-- Do nothing if a tool is being equipped
end
end
button.MouseButton1Click:Connect(onButtonClicked)
end)
game.ReplicatedStorage.SizeUp.OnServerEvent:Connect(function(plr)
local UserInputService = game:GetService("UserInputService")
local button = plr.PlayerGui.SizeUp.SizeUpB
-- Function to check if a tool is being equipped
local function isToolEquipped()
local character = plr.Character or plr.CharacterAdded:Wait()
for _, child in pairs(character:GetDescendants()) do
if child.ClassName == "Tool" then
return true
end
end
return false
end
-- Function to run when button is clicked
local function onButtonClicked()
if not isToolEquipped() then
-- Run the rest of the script
local character = plr.Character or plr.CharacterAdded:Wait()
local currentScale = character:GetScale()
if currentScale == 1.0 then
character:ScaleTo(1.5)
elseif currentScale == 0.5 then
character:ScaleTo(1.0)
end
else
-- Do nothing if a tool is being equipped
end
end
button.MouseButton1Click:Connect(onButtonClicked)
end)
i have versions of these for keyboard inputs too that arent connected to any remote events and also a local script that changes speed based on size let me know if you want to see those too
Ok please rewrite your server code to do what I mentioned up here:
As again detecting the button press on the server isnt needed, and it would be best to just do it on the client, and then tell the server to size up or down
game.ReplicatedStorage.SizeUp.OnServerEvent:Connect(function(plr)
local UserInputService = game:GetService("UserInputService")
-- Function to check if a tool is being equipped
local function isToolEquipped()
local character = plr.Character or plr.CharacterAdded:Wait()
for _, child in pairs(character:GetDescendants()) do
if child.ClassName == "Tool" then
return true
end
end
return false
end
-- Function to run when button is clicked
if not isToolEquipped() then
-- Run the rest of the script
local character = plr.Character or plr.CharacterAdded:Wait()
local currentScale = character:GetScale()
if currentScale == 1.0 then
character:ScaleTo(1.5)
elseif currentScale == 0.5 then
character:ScaleTo(1.0)
end
else
-- Do nothing if a tool is being equipped
end
end)
Not exactly sure this would work as I didnt test it, but it should do it, now anytime the remoteEvent is fired they will be sized up, you can do this same thing with the size down script as well!