Why i can't change the WalkSpeed

I know this is dumb, but i got a problem, when i try to change the WalkSpeed or the JumpHeight/JumpForce it doesn’t work, its just so basic that im amazed i can’t do it

local targetPlayer = findPlayerByName(argument2,player)
			if targetPlayer then
				local char = targetPlayer.Character or targetPlayer.CharacterAdded:Wait()
				local hrp = char:WaitForChild("HumanoidRootPart")
				local Workspace = game:GetService("Workspace")
				local rayOrigin = hrp.Position
				local raycastParams = RaycastParams.new()
				raycastParams.FilterDescendantsInstances = {char}
				raycastParams.FilterType = Enum.RaycastFilterType.Exclude
				local raycastResult = Workspace:Raycast(rayOrigin, Vector3.new(0,-100,0),raycastParams)
				if raycastResult then
					local hitPart = raycastResult.Position
					local door = ReplicatedS.AdminStorage:WaitForChild("Door"):Clone()
					door.Parent = workspace
					door:pivotTo(CFrame.new(hitPart,hitPart + hrp.CFrame.LookVector))
					local humanoid = char:WaitForChild("Humanoid")
					humanoid.WalkSpeed = 0
					humanoid.JumpPower = 0
				end
			end

humanoid its properly detected, i can print it and it comes right where it has to be
I KNOW about the workspace thing, it was 4 AM, ok?

This code is a warcrime.
Like why do you reinvent the wheel in? :skull:

Could you please click on humanoid it prints out in console so it selects a humanoid?
Pretty sure it prints wrong humanoid.

Also please cache damn referances, your code is unoptimized and is comically evil from optimization perspective.

4 Likes

Roblox’s own documentation refers to workspace in this way so many times it’s actually criminal. I’ve heard it be recommended to others as a “good” coding convention too. Not sure exactly why but hey ho.

I don’t care who wrote or tells that,
I only see how horribly it gets compiled into bytecode and useless VM overhead.
Also roblox did not have global variable workspace for a while so for them its forgivable, for people who encourage it meanwhile is not.

You are here to write code, not toying around with “wow code looks cool”
If convention is not compatible with language or has no any benefits then its to be declared invalid

Stop giving people authority without reason

Like Yarik said, this code is crazy.

There is already a “workspace” global keyword.
findPlayerByName is also already a standard function.
And you define stuff every time this code is ran for no reason - such as getting the workspace server each time or defining the raycastparams.

1 Like

I’m just checking, this doesn’t have anything to do with the solution, it’s more of a readability issue, raycastResult.Position will return the Vector3 of where the ray hit, not the instance position. your variable is named hitPart so I’d assume you want

local hitPart = raycastResult.Instance.Position

I understand why you’re trying to encourage good programming patterns, but in this scenario a single variable to refer to Workspace is definitely not an issue for compilation, its impact is almost negligible. The rest of the code I completely understand where you’re coming from, but the way you’re trying to convey that is incorrect, the forums are to help newer developers improve. Telling them their code sucks and it’s a “warcrime” is crazy. Nonetheless you also mention the topic of caching knowing full well by the structure of the code this is a newer developer and they most definitely won’t/shouldn’t focus on caching as a priority when their code is this disorganized.

4 Likes

Jesus, I was just saying it’s a thing that exists. The passive-agressive tone is not needed. Also you’re wrong about the “its old” arguement, just a heads up some roblox groups still promote it as their conventions and roblox themselves use it in more recently created documentation too.

Nobody is encouraging bad practices, but there’s a big difference between constructive critism and what you’re doing. People come here for help not to be berated, keep it positive dude. People literally come here to open up and accept help.

1 Like

I started foaming at the mouth after I saw this.

3 Likes

use remoteEvent and fire it then change the walkspeed & jumppower in server script not a localscript.

Is there any scripts that’s changing the walkspeed? Maybe u have a script that adjust’s the walkspeed back to normal.

mb, i was just trying not to fall asleep

theres only 2 scripts in that place, and neither of them change the walkspeed without something i do

as i said “humanoid its properly detected, i can print it and it comes right where it has to be”

i dont just search for the name, i do extra things, thats why i dont search the player directly into the players service

i think i just remembered what happened, some time ago i had the exact problem with another part of the script, it just didn’t worked for me in roblox studio, probably in Roblox player it would work

workspace always existed as a global, GetService(“Workspace”) is only used when fool devs rename the workspace in the explorer to something else

No, it’s not, lol. Where are your sources?
I clearly remember it not existing in 2019.

???

Global workspace points to the same object.
Workspace is a property of a game as well, so your logic makes no sense further.

that’s cause it was Workspace not workspace

it literally existed in a 2008 client