Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.