this is a lazy answer, there's probably a better one incoming but here's my lazy fix
first we define a variable that's called shotFired. this will be used to detect if the shot has been fired already. set it to false, and place it anywhere before the Activated event.
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local shotFired = false
script.Parent.Activated:Connect(
function()
if not debounce then
debounce = true
script.RemoteEvent:FireServer(mouse.Hit)
local hum = player.Character.Humanoid
for i = 1, 15 do
wait()
hum.CameraOffset = Vector3.new(math.random(-1, 1), math.random(-1, 1), math.random(-1, 1))
end
hum.CameraOffset = Vector3.new(0, 0, 0)
wait(2)
debounce = false
end
end
)
next, make it so that when you click, shotFired becomes true. do this by placing it inside the Activated event. also make sure it's inside the if not debounce statement, or else it could turn true without you firing a shot.
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local shotFired = false
script.Parent.Activated:Connect(
function()
if not debounce then
debounce = true
shotFired = true
script.RemoteEvent:FireServer(mouse.Hit)
local hum = player.Character.Humanoid
for i = 1, 15 do
wait()
hum.CameraOffset = Vector3.new(math.random(-1, 1), math.random(-1, 1), math.random(-1, 1))
end
hum.CameraOffset = Vector3.new(0, 0, 0)
wait(2)
debounce = false
end
end
)
next, add a check to see if a shot has been fired. if not, we can let the player shoot, but if a shot has been fired, we have to prevent the player from shooting.
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local shotFired = false
script.Parent.Activated:Connect(
function()
if not debounce and not shotFired then
debounce = true
shotFired = true
script.RemoteEvent:FireServer(mouse.Hit)
local hum = player.Character.Humanoid
for i = 1, 15 do
wait()
hum.CameraOffset = Vector3.new(math.random(-1, 1), math.random(-1, 1), math.random(-1, 1))
end
hum.CameraOffset = Vector3.new(0, 0, 0)
wait(2)
debounce = false
end
end
)
final code:
function onKeyPress(actionName, userInputState, inputObject)
local debounce = false
if userInputState == Enum.UserInputState.Begin then
print("X was pressed")
local debounce = false
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local shotFired = false
script.Parent.Activated:Connect(
function()
if not debounce and not shotFired then
debounce = true
shotFired = true
script.RemoteEvent:FireServer(mouse.Hit)
local hum = player.Character.Humanoid
for i = 1, 15 do
wait()
hum.CameraOffset = Vector3.new(math.random(-1, 1), math.random(-1, 1), math.random(-1, 1))
end
hum.CameraOffset = Vector3.new(0, 0, 0)
wait(2)
debounce = false
end
end
)
end
end
game.ContextActionService:BindAction("keyPressSpecialName", onKeyPress, true, Enum.KeyCode.X)
game.ContextActionService:SetPosition("keyPressSpecialName", UDim2.new(.5, 0, -.5, 0))
game.ContextActionService:SetImage("keyPressSpecialName", "rbxassetid://73737626")
37 comments
Where is the error?
I recognize this name from somewhere, hmmm...
hehe, i use to use scripting helpers alot
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
also i only play dungeon quest on this account
did you spam post lo