#help

1 messages · Page 1 of 1 (latest)

coral timber
#

why doesnt this script work? there arent any errors

hearty wedge
coral timber
#

still doesnt work

#

also its a localscript

coral timber
hardy portal
#

where is the script placed

hearty wedge
coral timber
#

under a tool

coral timber
sand sandal
#

maybe try instead of "player.Character.Humanoid.WalkSpeed = 25" try "Humanoid.WalkSpeed = 25"

#

cause you already defined humanoid

peak mason
#

if it does then its a problem on how your handling the inputs

sand sandal
#

and maybe replace Input.UserInputType to Input.KeyCode

peak mason
sand sandal
#

oh

coral timber
#

i also tried it with local tool = script.Parent at the start

#

which also didnt work

sand sandal
#

huh idk why its not working

#

wait so is the speed working and not toggling or is it just not working at all

hardy portal
#

tool.Equipped is a signal

#

like

peak mason
#

did i do it wrong?

coral timber
#

oh wait that's so true

hardy portal
#

tool.Equipped:Connect(function)

peak mason
hearty wedge
hardy portal
#

or that too

hardy portal
coral timber
#

wait

spare stumpBOT
#

studio** You are now Level 3! **studio

coral timber
#

sh

hardy portal
#
local UserInputService = game:GetService("UserInputService")
local tool = script.Parent

UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed then return end
    if input.KeyCode == Enum.KeyCode.E then
        if tool.Parent:FindFirstChild("Humanoid") then
            local character = tool.Parent
            local humanoid = character:WaitForChild("Humanoid")
            humanoid.WalkSpeed = 25
        end
    end
end)

#

try this

coral timber
#

peak

#

ty

hardy portal
#

np

coral timber
#

i have a question

#

if tool.Equipped is a signal

#

then how do I check for it

peak mason
coral timber
#

so i can only use it as a signal for a function?

#

there isnt a variable equivalent?

peak mason
coral timber
#

wait I'm stupid arent I

hardy portal
#

not directly from tool

coral timber
hardy portal
#

you can get a variable by checking if the tool is under the player's character or do something like:

local Tool = script.Parent
local ToolEquipped = false

Tool.Equipped:Connect(function()
  ToolEquipped = true
end)

Tool.Unequipped:Connect(function()
  ToolEquipped = false
end)
coral timber
#

ah i see

#

thank you very much

hardy portal
hardy portal
coral timber
coral timber
sand sandal
#

im gonna go ask gpt

hardy portal
#

you can add print everywhere

coral timber
#

oh yeah

sand sandal
#

this is what happened

hardy portal
sand sandal
#

local UserInputService = game:GetService("UserInputService")
local tool = script.Parent

UserInputService.InputBegan:Connect(function(Input, gameProcessed)
if gameProcessed then return end -- Optional: ignore if typing in chat

if Input.KeyCode == Enum.KeyCode.E then
    if tool:IsDescendantOf(game.Players.LocalPlayer.Character) then
        local Player = game.Players.LocalPlayer
        local Character = Player.Character
        if Character then
            local Humanoid = Character:FindFirstChild("Humanoid")
            if Humanoid then
                Humanoid.WalkSpeed = 25
            end
        end
    end
end

end)

hardy portal
#

what is that function

hardy portal
#

why do you put that inside the userinputservice.inputbegan part

coral timber
#

I want to make a player's movespeed 25 when they equip the tool

hardy portal
#

oh

sand sandal
#

huh

hardy portal
#

then remove the userinputservice part

#

and gameprocessed

sand sandal
#

i thought you wanted press e or smth

coral timber
#

like this?

coral timber
hardy portal
#

it is

#

also you can remove the print("y")

coral timber
#

doesnt print y either

hardy portal
#

i tried that in studio

#

and it works

coral timber
#

does it make your player faster

hardy portal
#
local tool = script.Parent
tool.Equipped:Connect(function() 
    local character = tool.Parent
    local humanoid = character:WaitForChild("Humanoid") 
    humanoid.WalkSpeed = 25
end)
coral timber
#

it definitely doesnt work for me

hardy portal
#

is it inside of the tool

#

the script

coral timber
#

its a localscript but yes

#

does it have to be a regular one

hardy portal
#

should still work

#

but only on the cliend

#

client

coral timber
#

it doesnt work for some reason

hardy portal
#

do you have any errors

coral timber
#

no

hardy portal
coral timber
#

yes

hardy portal
#

it should be the same thing

coral timber
#

i tried it

#

it did not work

hardy portal
#

add a print at the top of the script

coral timber
#

print works

hardy portal
#

and you said that the print inside of the .Equipped function dosent work

#

the one u had before

coral timber
#

yes

#

also doesnt work with the one you gave me

#

prints y but not x

hardy portal
#

do you have "requires handle" set to true inside of the tool

#

the property

coral timber
#

ye

hardy portal
#

does the tool have a handle

coral timber
#

no

#

wait im dumb arent i

hardy portal
#

set it to false

coral timber
#

alright im just gonna

#

I might be

hardy portal
coral timber
#

well

#

yeah i guess

#

thx for the positive reinforcement

hardy portal
#

np

#

does the tool work

coral timber
#

yes

hardy portal
#

you can also make it remove the extra speed by using tool.Unequipped

#

and setting the speed to 16

coral timber
#

yea

hardy portal
#

or any speed that you have by default in your game

coral timber
#

like this?

hardy portal
#

yes

coral timber
#

i have an error

#

it doesnt remove the speed

#

Infinite yield possible on 'Players.spammerton1.Backpack:WaitForChild("Humanoid")

hardy portal
#

ohh

#

oops

#

its bc the tool goes in the backpack

#

and is no longer in the character

coral timber
#

how do I solve it then

spare stumpBOT
#

studio** You are now Level 4! **studio

hardy portal
#

add

local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local humanoid = Character:WaitForChild("Humanoid")
``` add this at the start
#

i edited it

#

now

#

delete character = and humanoid = from inside of the functions

#

the whole lines

#

i edited the 3 lines again a bit

coral timber
#

like this?

hardy portal
#

i forgot that you used humanoid not Humanoid

#

change at the top the first letter of Humanoid

#

to h

coral timber
#

yea i did

#

nice it works

#

this is basically almost everything i need for now

#

thanks a ton