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

How do I make this script work with walls with a certain name?

Asked by
VVaffly -3
6 years ago
local player = game.Players.LocalPlayer
player.CharacterAdded:wait()
local character = player.Character
local torso = character:WaitForChild("Torso")
local mouse = player:GetMouse()
local humanoid = character:WaitForChild("Humanoid")

local lastwall = nil
mouse.KeyDown:connect(function(key)
    if string.byte(key) == 48 then
    local ray = Ray.new(
        torso.CFrame.p, torso.CFrame.lookVector *2
    )
    local hit, position, normal = workspace:FindPartOnRay(ray, character)

    if hit then
        if hit ~= lastwall then
            local velo = Instance.new("BodyVelocity",torso)
            velo.MaxForce = Vector3.new(300000,300000,300000)
            velo.Velocity =  -torso.CFrame.lookVector*40 + Vector3.new(0,50,0)
            game.Debris:AddItem(velo,0.1)
            lastwall = hit
            wait(.5)
            lastwall = nil
        end
    end
end
end)

Answer this question