I have always wanted to make an admin egg launcher gear like the one in all egg hunts before, where it launches an egg, and when a player touches the egg it awards a badge (only the first person who touched it gets it and then the egg disappears), how can I make one? Also is it possible if I replace the egg launched with (for instance) a hat or any other part?
Not too sure what to do here, since I do not have much experience with launchers and stuff.
I'll try my best, however.
Quick disclaimer: I don't know how to make it EXACTLY like in the egg hunts, e.g I might make it go slide and stuff.
First thing's first: Add a Remote Event into ReplicatedStorage. Name it whatever you like.
Second of all: Add a LocalScript inside the tool. Not the HANDLE, but the TOOL.
LocalScript:
local plr = game.Players.LocalPlayer -- Getting the player local tool = script.Parent local remoteEvent = game:GetService("ReplicatedStorage").NameHere -- Replace NameHere with your Remote Event name. script.Parent.Activated:Connect(function() remoteEvent:FireServer(script.Parent) end)
The client is DONE! Onto the server!
Add a Script inside ServerScriptService. Naming it is optional.
Also, add the egg part/hat part or whatever into ReplicatedStorage.
Script:
game.ReplicatedStorage.YourRemoteHere.OnServerEvent:Connect(function(plr,tool) -- Replace YourRemoteHere with your RemoteEvent's name local clone = game.ReplicatedStorage.Egg:Clone() -- Replace Egg with your items name clone.CanCollide = true -- This is important, or else it will fall out of the map clone.Anchored = false clone.Position = Vector3.new(tool.Handle.Money.Position.X, tool.Handle.Money.Position.Y, tool.Handle.Money.Position.Z + -5) clone.Parent = workspace -- The sound clone is optional, but useful. local soundclone = workspace.SoundNameHere:Clone() -- Replace SoundNameHere with your sound's name. soundclone.Parent = clone soundclone:Play() --[[ -- Also, mess around with the distance a bit. My settings for my sound clone are: RollOffMaxDistance: 50 RollOffMinDistance:10 RollOffMode: InverseTapered --]] local force = Instance.new("BodyForce",clone) force.Force = clone.CFrame.lookVector * 50 -- This applies force to the egg/hat or whatever so that it moves forward clone.Touched:Connect(function(hit) if hit.Parent then if hit.Parent:FindFirstChild("Humanoid") then local plr = game.Players:FindFirstChild(hit.Parent.Name) if plr then print("Somebody got the item!") -- Give them the badge. clone:Destroy() end end end end) game.Debris:AddItem(force,.5) -- This propels it slightly forward. You can change this if you like. game.Debris:AddItem(clone,5) -- You may want to change the 5 to 30 or 60 or something. game.Debris:AddItem(soundclone,soundclone.TimeLength) --And lastly, we simply use game.Debris to give a lifetime for the egg/sound/force. end)
Phew! That was alot! By the way, I have NOT tested this! Tell me if you have any problems.