so i want to make a roblox obby game where you have to carry an egg through the obby and…
- User
so i want to make a roblox obby game where you have to carry an egg through the obby and you try not to crack the egg. if you crack the egg you die and have to go back to your recent checkpoint. to crack the egg, the players egg bumps into a part and it cracks. another way they can crack the egg is by sprinting for too long and the egg falls. the player gets a sprint for lets say 3 seconds for now and if they go over 3 seconds, the egg falls. i want to start off with the picking up the egg to start the obby. how can i make it so the player presses E to pick up the egg? by the way the egg is not a real item its just a model i made called EggModel.
- Assistant
Here's a script to let the player pick up your EggModel by pressing E:
-- Place this script inside your EggModel local ProximityPromptService = game:GetService("ProximityPromptService") local Players = game:GetService("Players") -- Find or set the main part of the egg model local mainPart if script.Parent.PrimaryPart then mainPart = script.Parent.PrimaryPart else -- Find the first BasePart to use for _, part in pairs(script.Parent:GetDescendants()) do if part:IsA("BasePart") then mainPart = part script.Parent.PrimaryPart = part break end end end if not mainPart then error("EggModel needs at least one BasePart") end -- Create the proximity prompt that shows "Press E" local prompt = Instance.new("ProximityPrompt") prompt.ObjectText = "Egg" prompt.ActionText = "Pick Up" prompt.KeyboardKeyCode = Enum.KeyCode.E prompt.HoldDuration = 0 prompt.MaxActivationDistance = 10 prompt.Parent = mainPart -- Handle when player presses E ProximityPromptService.PromptTriggered:Connect(function(promptObj, player) if promptObj ~= prompt then return end local character = player.Character if not character then return end local humanoidRootPart = character:FindFirstChild("HumanoidRootPart") if not humanoidRootPart then return end -- Disable the prompt after pickup prompt.Enabled = false -- Position the egg in front of the player script.Parent:SetPrimaryPartCFrame(humanoidRootPart.CFrame * CFrame.new(0, 1, 2)) -- Attach the egg to the player local weld = Instance.new("WeldConstraint") weld.Name = "EggWeld" weld.Part0 = mainPart weld.Part1 = humanoidRootPart weld.Parent = mainPart -- Store the player who's carrying the egg script.Parent:SetAttribute("CarriedBy", player.UserId) end)Would you like me to explain how this code works or should we move on to implementing the sprint and egg cracking mechanics next?
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.