Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

runs touch function after been touched?

Asked by 4 years ago

hello I want when you press e and a specific part touches the player's right arm a function runs but now you must be outside the part then press e then go in the part then the function starts (so if you press e and you're inside the part the function does not want to start)

here is my local script:

local player = game:GetService('Players').LocalPlayer

local mouse = player:GetMouse()

game.Players.LocalPlayer:GetMouse().KeyDown:connect(function(k)

if k == "e" then

    script.Parent.THROW:FireServer()

    end

end)

and here is my normal script:

local player = script.Parent.Parent.Parent

local tho

tho = player.Character["Right Arm"].Touched:Connect(function(hit)

if hit.Parent and hit.Parent.ClassName == "Model" and hit.Name == "sticktowall" then

onacc(hit) --- onacc is the function that must run

tho:Disconnect()

I have other lines in my script like a lot but that is the part that must run the function when touched

Answer this question