#Hold E Problems

40 messages · Page 1 of 1 (latest)

charred lance
#

Having huge code problem, don't have any idea why its not working 💀
Ability im trying to make has 2 remotes, one for when the E button is released, and one for when it begins.
when it begins I try to make it constantly rotate the players root part toward the direction of the mouse,
however it prints fine and runs the code, and the move works . . . but it doesn't rotate the player?? so its not giving a error and not freezing at any part of the code??

local script:

server script:

tawny latch
#

Could you at least send it by using

Bla bla
#
Print("Hi")
thin lava
#
--Local script:
local tool = script.Parent
local UIP = game:GetService("UserInputService")
local Remote = tool:WaitForChild("RemoteEvent")
local player = game.Players.LocalPlayer
local detectholdremote = tool:WaitForChild("Detectedhold")

local char = player.Character
local root = char:WaitForChild("HumanoidRootPart")
local Debounce = 1
local anim = script.Animation

local track = char.Humanoid:LoadAnimation(anim)
local ic = script.InstaCast
local Tool = script.Parent
local toolquip = false
local hrp = char.HumanoidRootPart
local mouse = player:GetMouse()

local function Equipped()
    print(". . . Detected Equip")
toolquip = true
end

local function UnEquipped()
    print(" . . . Detected Unequip")
toolquip = false
end

Tool.Equipped:Connect(Equipped)
Tool.Unequipped:Connect(UnEquipped)
UIP.InputBegan:Connect(function(Input)
    if Input.KeyCode == Enum.KeyCode.E and Debounce == 1 and toolquip == true then
        print("Local Script Recieved Input . . .")
        Debounce = 2
        spawn(function()

        ic = true
        wait(0.41)
        ic = false
            
        end)
        root.Anchored = true
        detectholdremote:FireServer(player, char, track, Debounce)
        print("Fired Hold Remote")
        track:Play()
        wait(0.15)
        track:AdjustSpeed(0)

    end
end)

UIP.InputEnded:Connect(function(Input)
    if Input.KeyCode == Enum.KeyCode.E and Debounce == 2 then
        repeat wait() until ic == false
        print(". . . Sending To Server")
        track:AdjustSpeed(1)
        Debounce = 3
        Remote:FireServer(char, player, UIP, tool)
        print(". . . SENT . . .")
        wait(4) -- cooldown
        Debounce = 1
    end
end)
#
--Server script:
local remote = script.Parent.Parent.RemoteEvent
local replicated =  game:GetService("ReplicatedStorage")
local Modules = game.ReplicatedStorage.Modules
local misc = require(Modules.Misc)
local holdremote = script.Parent.Parent.Detectedhold

holdremote.OnServerEvent:Connect(function(player, char)
    local hrp = char:WaitForChild("HumanoidRootPart")
    local mouse = player:GetMouse()

    while true do
        wait()

        local lookVector = (mouse.Hit.Position - hrp.Position).Unit
        local lookRotation = CFrame.new(Vector3.new(), lookVector)

        hrp.CFrame = CFrame.new(hrp.Position) * lookRotation
    end
end)

remote.OnServerEvent:Connect(function(player, char, tool)
    print("Server Recieved Call From Client . . . Initiating")

local mouse = player:GetMouse()
    local explosion = replicated.FX.template2:Clone()

    local hrp = char:WaitForChild("HumanoidRootPart")

    hrp.Anchored = true

    explosion.Parent = workspace

    explosion.CFrame = CFrame.new((hrp.CFrame*CFrame.new(0, 0, 0)).Position)


    local hitList = {}

    explosion.Touched:Connect(function(hit)
        if hit.Parent:FindFirstChild("Humanoid") then
            local hitChar = hit.Parent --the character associated with the hit part

            if hitChar == char or hitList[hitChar] then return end --dont damage if hitChar is you or if hitChar has already been hit

            hitList[hitChar] = true --record that hitChar has been hit


            hitChar.HumanoidRootPart.CFrame = CFrame.lookAt(hitChar.HumanoidRootPart.Position, explosion.Position) * CFrame.Angles(0, math.pi, 0)
            local Damage = 50 -- Damage Amount
            hitChar.Humanoid:TakeDamage(Damage)
            misc.StrongKnockback(hit.Parent.HumanoidRootPart, 35, 45, 0.15, explosion)
        end
    end)

    wait(2)
    hrp.Anchored = false
    explosion:Destroy()
print("Operation Finished")
end)
#

@tawny latch

tawny latch
#

yeah I'll just focus on this when I have the free time..

charred lance
#

lol

#

the only problem is at the top of the server script

#

this:

`holdremote.OnServerEvent:Connect(function(player, char)
local hrp = char:WaitForChild("HumanoidRootPart")
local mouse = player:GetMouse()

while true do
    wait()

    local lookVector = (mouse.Hit.Position - hrp.Position).Unit
    local lookRotation = CFrame.new(Vector3.new(), lookVector)

    hrp.CFrame = CFrame.new(hrp.Position) * lookRotation
end

end)
`

isn't working how I want it too, (aka making the player face directly toward the mouse when the e button is held)

thin lava
charred lance
#

soo?
what do I do to fix?

thin lava
#

use raycasting

charred lance
#

.

#

how?

thin lava
#

2 sec

#

ima find an article

charred lance
#

also

#

my character isn't rotating at all

#

shouldn't mouse.hit.position work?

thin lava
#

wait nvm i though about mouse.Target, it does return a cframe although lookvector needs a vector3

thin lava
charred lance
#

it doesnt?

#

the prints run

#

but my guy dosn't rotate

thin lava
#

idk why

#

WAIT

#

i might know why

#

rotate the character on the client!

#

because of networking

#

the server might not be able to rotate the player

#

cuz the client owns the character

charred lance
#

ok

#

in local

#

its doing nothing?

#

how do i do it in local?

thin lava
#

Okay

#

Nvm

#

I got no idea