Another error, dont know whats going on

the script is supposed to change the characters walk speed when they touch a part. When I touch the part, it doesn’t work, and my walk speed doesn’t update.

game.StarterPlayer.CharacterJumpPower = 0
game.StarterPlayer.CharacterWalkSpeed = 4

game.Workspace.twlw["Lentilkac58-Easy-Teleport-1"].Touched:Connect(function(hit)
	game.StarterPlayer.CharacterJumpPower = 3
	game.StarterPlayer.CharacterWalkSpeed = 8
end)
1 Like

This won’t affect the players, you have to to it to the characters humanoid not the StarterPlayer

Put this script inside the Lentilkac58-Easy-Teleport-1 part

script.Parent.Touched:Connect(function(hit)
    local human = hit.Parent:FindFirstChild("Humanoid")
    if human then
        human.WalkSpeed = 8
        human.JumpPower = 3
    end
end)
2 Likes

thank you! will try to do that, see if it works

1 Like

So you should add this line after changing values. Anyways it’s better using the script above my post.

if game.Players:GetPlayerFromCharacter(hit.Parent) then -- Is a player.
    local Humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid")
    Humanoid.WalkSpeed = game.StarterPlayer.CharacterWalkSpeed
    Humanoid.JumpPower = game.StarterPlayer.JumpPower
end
1 Like

How do I increase the speed when the part is touched then?

game.StarterPlayer.CharacterJumpPower = 0
game.StarterPlayer.CharacterWalkSpeed = 4

game.Workspace.twlw["Lentilkac58-Easy-Teleport-1"].Touched:Connect(function(hit)

if game.Players:GetPlayerFromCharacter(hit.Parent) then -- Is a player.
	local Humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid")
	Humanoid.WalkSpeed = game.StarterPlayer.CharacterWalkSpeed
	Humanoid.JumpPower = game.StarterPlayer.CharacterJumpPower 
	end
	end)

[/quote]

1 Like

Did you try the script I shared??

1 Like

I did, got this error

Touched is not a valid member of Workspace "Workspace

1 Like

I told you, you need to parent this script to the

Part in the workspace, not the workspace itself.

Since this is the solution, the script is:

2 Likes