I am making a game and I got a pizza delivery system model. To pick up the pizza I have to press E, I want it so when you pick up the pizza, you click on it instead of having to press E.
local pzname = script.Parent.PizzaName
local player = game.Players.LocalPlayer
local char = player.Character
local humanoid = char:WaitForChild('Humanoid')
-- [KNEEL]
function onKeyPress(inputObject, gameProcessedEvent)
if(gameProcessedEvent == true) then return end
if inputObject.KeyCode == Enum.KeyCode.E and script.Parent.PizzaSelected.Value == 'true' and script.Parent.HasPizza.Value == 'false' then
game.ReplicatedStorage.Pizza.DeliverBox:FireServer()
script.Parent.HasPizza.Value = 'true'
workspace:FindFirstChild("Pizzas"):FindFirstChild(pzname.Value).Transparency = 1
---[Local sided for you want the player only to see the change but others see you delivering it]
workspace:FindFirstChild("Pizzas"):FindFirstChild(pzname.Value).ClickDetector.MaxActivationDistance = 0
local chosen = math.random(1,2) -- [TOTAL Amount of NPCS to deliver too]
if chosen == 1 then
local npcname = 'Delivery1' --- Change name per npc
game.ReplicatedStorage.Pizza.NPCSpawn:FireServer(npcname)
script.Parent.Parent.Marker.Enabled = true
wait(1)
local point = game.ReplicatedStorage.Markers.Pos
point.Position = workspace.DeliPerson.Torso.Position -- Change name "DeliPerson" to the npc model name
elseif chosen == 2 then
local npcname = 'Delivery2' --- Change name per npc
game.ReplicatedStorage.Pizza.NPCSpawn:FireServer(npcname)
script.Parent.Parent.Marker.Enabled = true
wait(1)
local point = game.ReplicatedStorage.Markers.Pos
point.Position = workspace.DeliPerson2.Torso.Position -- Change name "DeliPerson" to the npc model name
end
wait(10) -- Cooldown until pizza respawns
workspace:FindFirstChild("Pizzas"):FindFirstChild(pzname.Value).ClickDetector.MaxActivationDistance = 10
workspace:FindFirstChild("Pizzas"):FindFirstChild(pzname.Value).Transparency = 0
else
end
end
game:GetService("UserInputService").InputBegan:Connect(onKeyPress)
https://www.roblox.com/library/4472393205/PokePizzaDeliverySystem
