Scripting Error?

So I was trying to script something where you can type your speed value.
Here’s the script.
Value.Text is where I will be inserting the value in-game.

local repStorage = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local Event = repStorage:WaitForChild("Speed")
local List = game.StarterGui.Admin2.Commands.List.TextButton
local value = game.StarterGui.Admin2.Commands.Value.Text

Event.OnServerEvent:Connect(function(plr, targetName)
	local target = players:FindFirstChild(targetName)
	if target then --check for the player (again cuz the check on the client is bypassable with exploits)
		
		local char = plr.Character
		if char then
			local hum = char:FindFirstChildOfClass("Humanoid")
			if hum then
				hum.WalkSpeed = value

			end
		end -- Your script to kill here (target is the player to kill)
		
		print(plr.Name .. " speed " .. targetName)
	end
end)
2 Likes

you have to convert value to number with

hum.WalkSpeed =tonumber(value)
2 Likes

I did so but didn’t work as well
Edit:One of the problems was because of the ReplicatedStorage Target being wrong,corrected it now but still doesn’t fix it.

1 Like

what output do you have? What your problem?

1 Like

It didn’t appear anything as error,just printed
':arrow_forward: Cypacic speed Cypacic (x4) ’
as expected

1 Like

Your main issue is that you’re using StarterGui and not PlayerGui.

1 Like

Idk why but it broke instead,now it didn’t even print what I expect

1 Like

This variable is indicating that you’ve already got the text string set up, which is defined as whatever you first set the text with

Just do

local value = game.StarterGui.Admin2.Commands.Value

And when you set your walkspeed, do:

hum.WalkSpeed = tonumber(value.Text)

So that you have the Instance, but not the Instance’s property saved

1 Like

PlayerGui is accessed from the Player instance. Whatever someone types into a textbox, it’s only visible to the client so you need to send that with the remote event.

1 Like

try

local repStorage = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local Event = repStorage:WaitForChild("Speed")
local List = game.StarterGui.Admin2.Commands.List.TextButton


Event.OnServerEvent:Connect(function(plr, targetName)
	local target = players:FindFirstChild(targetName)
	if target then --check for the player (again cuz the check on the client is bypassable with exploits)
		local value = plr.PlayerGui.Admin2.Commands.Value.Text
		local char = plr.Character
		if char then
			local hum = char:FindFirstChildOfClass("Humanoid")
			if hum then
				hum.WalkSpeed = tonumber(value)

			end
		end -- Your script to kill here (target is the player to kill)
		
		print(plr.Name .. " speed " .. targetName)
	end
end)

do the same with List

1 Like

tried all of your suggestions,
they all sound reasonable,it’s kinda strange on how they’re not working
any more suggestion guys?

what you mean is what polloarrosto01 suggested right?

1 Like

did u try polloarrosto01’s script? .Text returns a string value not an int value, converting it with tonumber() might work

1 Like

Partially, just send the value of the text to the server instead of getting the gui.

RemoteEvent:FireServer(target, speed)

The textbox would be blank on the server.

1 Like

where do I put this script at?

1 Like

do I put tonumber(value) or just tonumber()

1 Like

In the script you use to send the event to the server.

1 Like

Replace ‘hum.WalkSpeed = value’ in your script with this:

hum.WalkSpeed =tonumber(value)

It will convert the Value.Text into a number value

1 Like

Unknown Global for ‘speed’
And do I change RemoteEvent to my Event’s Name?

1 Like

Change ‘speed’ to the textbox’s text. It was an example on how to do it.

1 Like