#script dont work

1 messages · Page 1 of 1 (latest)

manic ibex
#

local Players = game:GetService("Players")
local ProximityPromptService = game:GetService("ProximityPromptService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local FoodModels = ReplicatedStorage:WaitForChild("Foods")
local Animations = ReplicatedStorage:WaitForChild("Animations")

local function attachFoodToHead(player: Player, foodName: string)
local character = player.Character
if not character then return end

local humanoid = character:FindFirstChildOfClass("Humanoid")
local head = character:FindFirstChild("Head")
if not humanoid or not head then return end

-- Prevent carrying multiple foods
if character:FindFirstChild("CarriedFood") then return end

local foodTemplate = FoodModels:FindFirstChild(foodName)
if not foodTemplate then return end

local clone = foodTemplate:Clone()
clone.Name = "CarriedFood"

-- Disable physics
for _, obj in clone:GetDescendants() do
    if obj:IsA("BasePart") then
        obj.CanCollide = false
        obj.Anchored = false
    end
end

-- Disable the ProximityPrompt on the clone
local prompt = clone:FindFirstChildOfClass("ProximityPrompt")
if prompt then
    prompt.Enabled = false
end

clone.Parent = character
clone:PivotTo(head.CFrame * CFrame.new(0, 2, 0))

local weld = Instance.new("WeldConstraint")
weld.Part0 = head
weld.Part1 = clone.PrimaryPart
weld.Parent = clone.PrimaryPart

-- Play holding animation if available
local animator = humanoid:FindFirstChildOfClass("Animator")
if not animator then
    animator = Instance.new("Animator")
    animator.Parent = humanoid
end

local holdAnim = Animations:FindFirstChild("HoldAnim")
if holdAnim then
    local track = animator:LoadAnimation(holdAnim)
    track:Play()
end

end

#

ProximityPromptService.PromptTriggered:Connect(function(prompt, player)
if not player or not player.Character then return end

local foodModel = prompt:FindFirstAncestorWhichIsA("Model")
if not foodModel then return end
if foodModel.Name == "CarriedFood" then return end

-- Remove the world food
local foodName = foodModel.Name
foodModel:Destroy()

-- Attach a new cloned food to the player's head
attachFoodToHead(player, foodName)

end)

#

and i used ai 😭

#

so pls help

quick ivy
manic ibex
#

i already know some scripting but i tried using ai to fix what i had done but it just ruined it