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?
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
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.
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
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.
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.
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