Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you change the players walkspeed when on a different smooth terrain Material ?

Well, I am trying to make players walk faster on Cobblestone paths and Dirt Paths then again also force players that walk on grassy terrain to be slower.

I have put some research into this which resulted in even more questions. Like for example what raycasting is. ( Couldn't find a lead with raycasting either ) I am honestly at a loss and hope that somebody could help me.

Note that I have almost no Scripting background but I would like to implement this into my game.

I am unsure if I require a code? Maybe I do.

Thank you in advance.

1 comment

0

Look into to region3

2 answers

✓ Accepted answer

Hello, romania34!

There're some ways you can do this...


1 - Region3

May be a little bit confusing, as Region3 is a bit advanced, but its a easy way to do...

You can create a Region3 on a area and then detect if user is in Region3

Add that in a loop and you will have it working...

2 - Humanoid.FloorMaterial (side-note: may be glitchy when user jump if you don't make it correctly, but its easier because you can simply add paths without adding anything else)

You can detect for user FloorMaterial in loop, and change the walk speed based on that.


API Reference

Humanoid

Humanoid.WalkSpeed

Humanoid.FloorMaterial

Region3

Find parts in Region3


Hope this helps you achieve what you are trying to do, if so, please mark the answer as accepted.


I'm not giving you any code because Scripting Helpers is not a request website

1 comment

0

Heya, thank you very much. I actually researched it and found some tutorials on to how region 3 works, but as I have no scripting background and no idea what I am doing i tried scripting something myself and i dont paticularly know why it isnt working... Uhh I dont know if I should as this in the comments either but here goes.

This is what I managed to come up with, is it worth anything I do not know if I should start a new post on this so I am just writing a comment.

-- Walk Speed Testing

local region = Region3.new(Vector3.new(0,0,0), Vector3.new(15,15,15))

local part = Instance.new ('Part') part.Anchored = true part.Size = region.Size part.Parent = game.Workspace part.CanCollide = false part.Transparency = 0.5

while true do wait() local partsInRegion = workspace:FindPartsInRegion3(region,part,1000) for i, part in pairs(partsInRegion)do if part.Parent:FindFirstChild('Humanoid') ~= nil then print('Player Found in the region!:'.. part.Parent.Name) local player = game.Players.LocalPlayer local char = player.CharacterAdded:wait() local h = char.Humanoid h.WalkSpeed = 17.5 end end end

I am unsure why it isn't working. Could anybody help me out ?

1 comment

0

Actually, you should post a new question, as this one was already answered

This discussion is preserved as it was. New answers, comments, and votes are closed.