#how do i make this work
1 messages · Page 1 of 1 (latest)
set number inside the function
but im making it that you can change the number
i'll send some code in a second that should work
ok
@snow schooner try this
local Players = game:GetService("Players") -- game.Players
local rig = workspace.Rig
local humanoid = rig:WaitForChild("Humanoid") -- get the humanoid inside the rig
local frame = script.Parent.Gui.Frame
frame.TextButton.MouseButton1Click:Connect(function()
local userId = frame.TextBox.Text -- get the current Text of the TextBox when the button is clicked
local description = Players:GetHumanoidDescriptionFromUserId(userId)
humanoid:ApplyDescription(description)
end)
was there an error?
no it just didnt work
** You are now Level 1! **
ok one sec
scripting is so cool yet so hard to do 💔
its a script (white one)
yes that means its running on roblox's server, which cant see whatever you type in the textbox cause thats limited to your client
oh so do local?
not exactly because only on the server can you do Players:GetHumanoidDescriptionFromUserId(...)
so you have to send a message to the server whenever you click the button, telling it what user id to load
you can do that with remote events
hm
put one of these in replicated storage
name it like "LoadUserId" or whatever
there
and then you can make a local script that basically does
LoadUserId:FireServer(frame.TextBox.Text)
when you click the button
and then a separate server script will handle the actual loading the rig
i will send the code
yes. put a local script inside the TextButton:
local ReplicatedStorage = game:GetService("ReplicatedStorage") -- game.ReplicatedStorage (where the remote events should be)
local Players = game:GetService("Players")
local LoadUserId = ReplicatedStorage:WaitForChild("LoadUserId") -- get the remote event
script.Parent.MouseButton1Click:Connect(function()
local userId = script.Parent.Parent.TextBox.Text
LoadUserId:FireServer(userId)
end)
And put a server script (white one) inside "ServerScriptService" with this code:
local ReplicatedStorage = game:GetService("ReplicatedStorage") -- game.ReplicatedStorage (where the remote events should be)
local LoadUserId = ReplicatedStorage:WaitForChild("LoadUserId") -- get the remote event
local Players=game:GetService("Players")
local rig = workspace:WaitForChild("Rig")
local humanoid = rig:WaitForChild("Humanoid")
LoadUserId.OnServerEvent:Connect(function(player, userId) -- player = client who fired, userId = text from the textbox
local description = Players:GetHumanoidDescriptionFromUserId(tonumber(userId))
humanoid:ApplyDescription(description)
end)
make sure the local script is inside the text button and the server script is in ServerScriptService