Ad
Log in to vote
0

How to change the script that's executed when using a hold button to loop script?

Asked by 12 days ago
Edited 12 days ago

Hey there! Sorry if this is a dumb question. I am still at a basic level of scripting and learning every day.

I had this script working perfectly for teleporting back and forth as you can see:

local pressed = false
local client = game:GetService("Players").LocalPlayer
game:GetService("UserInputService").InputBegan:connect(function(input, gpe)
    if gpe then return end

    if input.KeyCode == Enum.KeyCode.V then
    pressed = true
    while pressed == true do

        client.Character:SetPrimaryPartCFrame(CFrame.new(275,3.94,347.568))
        wait(0.1)
        client.Character:SetPrimaryPartCFrame(CFrame.new(275,5.94,347.568))
        wait(0.1)

        end
    end
end)

But instead of this teleport script:

        client.Character:SetPrimaryPartCFrame(CFrame.new(275,3.94,347.568))
        wait(0.1)
        client.Character:SetPrimaryPartCFrame(CFrame.new(275,5.94,347.568))
        wait(0.1)

I need it to execute this script below:

local A_1 = "police"
local A_2 = -1
local Event = game:GetService("ReplicatedStorage").RPC["Businesses_Purchase"]


Event:FireServer(A_1, A_2)

Can someone explain how to do this? I am curious because nothing I try seems to be working. I greatly appreciate it!

0
Show what you have done DinozCreates 241 — 12d

Answer this question