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

You see the script works but I wanted to see if I could keep changing "fp" position?

Asked by 2 years ago

I wanna change "fp" cframe constantly

local UIS = game:GetService("UserInputService")
local hotkey = Enum.KeyCode.Q
local cooldown = 10
local event = game:GetService("ReplicatedStorage").Remotes.eventq
local fp = game.Workspace.FIRE 

local plr = game:GetService("Players").LocalPlayer

UIS.InputBegan:Connect(function(input)
    if input.KeyCode == hotkey then
        if tick() - plr.Cooldown.Value > cooldown then
            local fpl = plr.Character:WaitForChild("HumanoidRootPart").Position

            fp.CFrame = CFrame.new(fpl)
            fp.ParticleEmitter.Enabled = true
            event:FireServer(cooldown)
            wait(cooldown)
            fp.CFrame = CFrame.new(1721.725, 2511.404, -1099.142)
            fp.ParticleEmitter.Enabled = false
        end
    end
end)

1 answer

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
2 years ago
local UIS = game:GetService("UserInputService")
local RS = game:GetService("RunService")
local hotkey = Enum.KeyCode.Q
local cooldown = 10
local event = game:GetService("ReplicatedStorage").Remotes.eventq
local fp = game.Workspace.FIRE 
local plr = game:GetService("Players").LocalPlayer

RunService.RenderStepped:Connect(function()
    if UIS:IsKeyDown(hotkey) then
        if tick() - plr.Cooldown.Value > cooldown then
            local fpl = plr.Character:WaitForChild("HumanoidRootPart").Position

            fp.CFrame = CFrame.new(fpl)
            fp.ParticleEmitter.Enabled = true
            event:FireServer(cooldown)
            wait(cooldown)
            fp.CFrame = CFrame.new(1721.725, 2511.404, -1099.142)
            fp.ParticleEmitter.Enabled = false
            end
    end
end)

The concept of this script is to make an infinite loop, and check if Q is getting pressed each time. If Q is getting pressed, it will update the fp's position.

This code uses UIS:IsKeyDown(hotkey) for simplicity's sake. I don't know about the false positives lol

Ad

Answer this question