#Script uses same clone

11 messages · Page 1 of 1 (latest)

fading burrow
#

This is a basic problem probably, when the p[layer presses E it does spawn the egg, but after pressing it again it seems to use the same egg, I want to have it use a seperate clone for each press. local Egg = game.ReplicatedStorage.Egg:Clone()
local EggSpawn = script.Parent["Egg Spawn"]
local Playerparent = game.Players.LocalPlayer.Character.Parent.Parent.Eggs

local userInputService = game:GetService("UserInputService")

local function onKeyPress(input)
if input.KeyCode == Enum.KeyCode.E then
Egg:SetPrimaryPartCFrame(EggSpawn.CFrame)
Egg.Parent = Playerparent
end
end

userInputService.InputBegan:Connect(onKeyPress)

dusky heartBOT
#

studio** You are now Level 1! **studio

split harbor
#

Its because youre only cloning the egg once

#

And then reusing the same egg over and over again

#

Instead you should clone another one every time the player presses E

fading burrow
#

How would I do that?

split harbor
#

move the first line inside the if statement

#

if input.KeyCode == Enum.KeyCode.E then
local Egg = game.ReplicatedStorage.Egg:Clone()
Egg:SetPrimaryPartCFrame(EggSpawn.CFrame)
Egg.Parent = Playerparent
end

#

also next time please

fading burrow
#

Thank you so much your the best!!!!!!!!!!!!!!!!