I want to make a pizza that can give to NPC when you touched them. However, I don’t know how to do it.
Set the player’s pizza tool to the NPC’s model on .Touched
Nevermind, I did it. Here the code:
local Players = game:GetService("Players")
local goldChunk = script.Parent
local function onPartTouch(otherPart)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
-- Destroy the pickup
goldChunk:Destroy()
-- Update the player's leaderboard stat
local player = Players:GetPlayerFromCharacter(partParent)
local leaderstats = player.leaderstats
local goldStat = leaderstats and leaderstats:FindFirstChild("Money") -- Change anything you want for example, Gold, Cash, etc
if goldStat then
goldStat.Value = goldStat.Value + 100
end
end
end
--Change game.Workspace.Special.t4_3xy.Torso any you want (Just make sure you select is part, not model)
game.Workspace.Special.t4_3xy.Torso.Touched:Connect(onPartTouch)