No…That just stores the current text of the Textbox, you need to give it the textbox where you write the amount of speed to give to someone
Let’s just place the LocalScript
in the GuiObject
for easier reference, and not inside the TextBox
itself
What you’d wanna do, is assign your variables to where you want your specific TextBox
’s to be
You’ll need to create another TextBox
object inside your ScreenGui
, but this one will handle the Speed to change the Target:
local Event = game.ReplicatedStorage:WaitForChild("SpeedEvent")
local GuiObject = script.Parent
local TargetBox = GuiObject.TargetBox
local SpeedBox = GuiObject.SpeedBox
TargetBox.FocusLost:Connect(function(PressedEnter)
if PressedEnter then
Event:FireServer(TargetBox.Text, SpeedBox.Text) --This will be passed onto the server to receive
end
end)
Spelling mistake!
Okay t h e n
You could also add a confirm button if you want to get a bit more fancy, I also just realized another mistake hold on
What do you mean by that? Is it a Property? (My brain is fried)
It’s literally an object that’s having to do with the Gui itself (Or what you have on your StarterGui
objects)
(Examples: Frame
, TextBox
, ImageLabel
)
Oh so i put the LocalScript
in the Frame
?
If the Frame
is parented outside both the TextBox
Objects, then yes
The TextBoxes are parented in the Frame
.
That’s literally the same thing
Just put the LocalScript
inside the Frame
Oh thanks, now i just need to use tonumber becuase Text
is a String.
Oh no. How do i use tonumber? Becuase now it does nothing than setting the WalkSpeed
to nil.
Can I see the current script you’re using?
local speedEvent = game.ReplicatedStorage:WaitForChild(“SetSpeedEvent”)
speedEvent.OnServerEvent:Connect(function(PlayerWhoFired, TargetPlayer, Speed)
local player = game:GetService(“Players”):FindFirstChild(TargetPlayer)
if not player or not player.Character then
return
end
player.Character.Humanoid.WalkSpeed = tonumber(Speed)
end)
(Sorry if it looks like this, but i don’t know where’s the LUA layout button!)
Anyways, maybe you can implement a couple of sanity checks?
local speedEvent = game.ReplicatedStorage:WaitForChild(“SetSpeedEvent”)
speedEvent.OnServerEvent:Connect(function(PlayerWhoFired, TargetPlayer, Speed)
print(Speed)
local player = game:GetService(“Players”):FindFirstChild(TargetPlayer)
if not player or not player.Character or typeof(Speed) ~= "string" then
return
end
player.Character.Humanoid.WalkSpeed = tonumber(Speed)
end)
Here’s what it gave me:
19:09:16.905 Infinite yield possible on 'ServerStorage:WaitForChild("AdminPanel")' - Studio
19:09:16.905 Stack Begin - Studio
19:09:16.905 Script 'ServerScriptService.AdminPanelScript', Line 8 - Studio - AdminPanelScript:8
19:09:16.905 Stack End - Studio
19:09:37.387 - Server - SetSpeedScript:4
I think it’s a nothing.
Hm
Try printing out the other variables as well, and see if they print out anything back?
I don’t know if i made a mistake with the Script
, but when i pressed enter while i was entering my Username, it printed this: 19:14:39.709 thatrandomnoob23 - Server - SetSpeedScript:5
Yeah that’s supposed to happen, the script will detect if you’ve either left the TextBox
via clicking off of it, or by pressing enter
Actually now that I think about it, I maybe know the reason why
Try creating 1 TextButton
(Not a TextBox
), this will be the confirmation button that what you want to send is valid
local Event = game.ReplicatedStorage:WaitForChild("SpeedEvent")
local GuiObject = script.Parent
local TargetBox = GuiObject.TargetBox
local SpeedBox = GuiObject.SpeedBox
local ConfirmButton = GuiObject.Confirm
ConfirmButton.MouseButton1Down:Connect(function()
Event:FireServer(TargetBox.Text, SpeedBox.Text) --This will be passed onto the server to receive
end)
I believe what is happening is cause the script is only detecting for the TargetBox
if it fires at all, when you should be confirming the action on both Texts
to send to the server
Same thing happens.
19:23:12.689 thatrandomnoob23 - Server - SetSpeedScript:5