Hello, Everybody
I am making an egg hatching system and when a player clicks E to purchase the egg then the egg will open, but for some reason, the script thinks the player is not clicking E even though the player is clicking E and the coins requirement is met on script. No errors
LOCAL SCRIPT
local OpenEggButton = script.Parent
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local UIS = game:GetService("UserInputService")
local function InputBegan(input,Processed)
if input.UserInputType == Enum.KeyCode.E then
print("input considered")-- right here print does not run
if plr.leaderstats.Coins.Value >= 25000000 then
plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value - 25000000
print("Purchase was sucessful")
local EggC = workspace.Eggs["EggMesh6"]
local EggCFrame = CFrame.new(-225.319, 13.65, -399.841)
EggC.CFrame = EggCFrame
local function EggHatchFunction()
local PetHatchedScreenUI = game.Players.LocalPlayer.PlayerGui.PetHatchedScreenUI
PetHatchedScreenUI.Enabled = true
EggC.Parent = game.Players.LocalPlayer.PlayerGui.PetHatchedScreenUI.EggViewportFrame
local VFP = game.Players.LocalPlayer.PlayerGui.PetHatchedScreenUI.EggViewportFrame
VFP.CurrentCamera = game.Workspace.Camera
local Camera = game.Workspace.Camera
Camera.CameraSubject = EggC
Camera.DiagonalFieldOfView = 15
Camera.CameraType = Enum.CameraType.Watch
local MagEript = game.Players.LocalPlayer.PlayerScripts.MagnitudeEggScript6
MagEript.Disabled = true
local BSE = game.Players.LocalPlayer.PlayerGui.LavaWorldPets
BSE.Enabled = false
wait(0.5)
EggC.Orientation += Vector3.new(15,90,0)
wait(0.2)
EggC.Orientation -= Vector3.new(20,90,0)
wait(0.2)
EggC.Orientation += Vector3.new(30,90,0)
wait(0.2)
EggC.Orientation -= Vector3.new(30,90,0)
wait(0.2)
EggC.Orientation += Vector3.new(60,90,0)
wait(0.2)
EggC.Orientation -= Vector3.new(60,90,0)
wait(0.2)
EggC.Orientation += Vector3.new(40,90,0)
wait(0.2)
EggC.Orientation -= Vector3.new(52,90,0)
Camera.CameraSubject = char:WaitForChild("Humanoid")
Camera.CameraType = Enum.CameraType.Custom
Camera.DiagonalFieldOfView = 123.118
MagEript.Disabled = false
EggC.CFrame = CFrame.new(-225.319, 13.65, -399.841)
EggC.Parent = game.Workspace.Eggs
end
--
--
--
--
--
--
--
--
--
--
--
local function PetPicker()
local Pets = require(game.ReplicatedStorage.PetsModuleScript)
local PetHatchedScreenUI = game.Players.LocalPlayer.PlayerGui.PetHatchedScreenUI
local PetViewPortFrame = PetHatchedScreenUI.Frame.PetViewPortFrame
local Rarity = PetHatchedScreenUI.Frame.RarityTextBox
local PetName = PetHatchedScreenUI.Frame.PetNameTextBox
EggHatchFunction()
local petChance = math.random(90,100)
print(petChance)
if petChance <=30 then
PetHatchedScreenUI.Enabled = true
local Camera = game.Workspace.Camera
Pets.HellCat.Parent = PetViewPortFrame
PetViewPortFrame.CurrentCamera = game.Workspace.Camera
Camera.CameraSubject = Pets.HellCat
local YouHatched = PetHatchedScreenUI.Frame.YouHatchedA
YouHatched.Text = "You Hatched A !!!"
Rarity.Text = "Common"
PetName.Text = "HellCat"
wait(2)
PetHatchedScreenUI.Enabled = false
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded
local hum = char.Humanoid
Camera.CameraSubject = hum
Rarity.Text = ""
PetName.Text = ""
YouHatched.Text = ""
local MagEript = game.Players.LocalPlayer.PlayerScripts.MagnitudeEggScript6
MagEript.Disabled = false
Pets.HellCat.Parent = game.ReplicatedStorage.Pets.LavaWorldPets
local HellCatF = Instance.new("Folder")
HellCatF.Name = "HellCat"
HellCatF.Parent = game.Players.LocalPlayer.PetsFolder
local DamageValue = Instance.new("IntValue")
DamageValue.Name = "DamageValue"
DamageValue.Value = 2955 *4.9
DamageValue.Parent = HellCatF
local EquippedValue = Instance.new("StringValue")
EquippedValue.Name = "EquippedValue"
EquippedValue.Value = "Unequipped"
EquippedValue.Parent = HellCatF
----------------------------------------------------------
local Storage = game.Players.LocalPlayer.PlayerGui.Storage
local template = Storage.template:Clone()
template.Name = "template"
local JungleCatF2 = Instance.new("Folder")
JungleCatF2.Name = "HellCat"
JungleCatF2.Parent = template
local RarityValue2 = Instance.new("StringValue")
RarityValue2.Name = "Rarity"
RarityValue2.Value = "Common"
RarityValue2.Parent = template
local DamageValue2 = Instance.new("IntValue")
DamageValue2.Name = "DamageValue"
DamageValue2.Value = 2955 *4.9
DamageValue2.Parent = template
local EquippedValue2 = Instance.new("StringValue")
EquippedValue2.Name = "EquippedValue"
EquippedValue2.Value = "Unequipped"
EquippedValue2.Parent = template
template.Parent = game.Players.LocalPlayer.PlayerGui.Inventory.LowerInvFrame.ScrollingFrame
elseif petChance >=31 and petChance <=60 then
PetHatchedScreenUI.Enabled = true
local Camera = game.Workspace.Camera
Pets.BurntDog.Parent = PetViewPortFrame
PetViewPortFrame.CurrentCamera = game.Workspace.Camera
Camera.CameraSubject = Pets.BurntDog
local YouHatched = PetHatchedScreenUI.Frame.YouHatchedA
YouHatched.Text = "You Hatched A !!!"
Rarity.Text = "Common"
PetName.Text = "BurntDog"
wait(2)
PetHatchedScreenUI.Enabled = false
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded
local hum = char.Humanoid
Camera.CameraSubject = hum
Rarity.Text = ""
PetName.Text = ""
YouHatched.Text = ""
local MagEript = game.Players.LocalPlayer.PlayerScripts.MagnitudeEggScript6
MagEript.Disabled = false
Pets.BurntDog.Parent = game.ReplicatedStorage.Pets.LavaWorldPets
local BurntDogF = Instance.new("Folder")
BurntDogF.Name = "BurntDog"
BurntDogF.Parent = game.Players.LocalPlayer.PetsFolder
local DamageValue = Instance.new("IntValue")
DamageValue.Name = "DamageValue"
DamageValue.Value = 2955 * 4.9
DamageValue.Parent = BurntDogF
local EquippedValue = Instance.new("StringValue")
EquippedValue.Name = "EquippedValue"
EquippedValue.Value = "Unequipped"
EquippedValue.Parent = BurntDogF
----------------------------------------------------------
local Storage = game.Players.LocalPlayer.PlayerGui.Storage
local template = Storage.template:Clone()
template.Name = "template"
local JungleCatF2 = Instance.new("Folder")
JungleCatF2.Name = "BurntDog"
JungleCatF2.Parent = template
local RarityValue2 = Instance.new("StringValue")
RarityValue2.Name = "Rarity"
RarityValue2.Value = "Common"
RarityValue2.Parent = template
local DamageValue2 = Instance.new("IntValue")
DamageValue2.Name = "DamageValue"
DamageValue2.Value = 2955 *4.9
DamageValue2.Parent = template
local EquippedValue2 = Instance.new("StringValue")
EquippedValue2.Name = "EquippedValue"
EquippedValue2.Value = "Unequipped"
EquippedValue2.Parent = template
template.Parent = game.Players.LocalPlayer.PlayerGui.Inventory.LowerInvFrame.ScrollingFrame
elseif petChance >=61 and petChance <=80 then
PetHatchedScreenUI.Enabled = true
local Camera = game.Workspace.Camera
Pets.SkeletonFly.Parent = PetViewPortFrame
PetViewPortFrame.CurrentCamera = game.Workspace.Camera
Camera.CameraSubject = Pets.SkeletonFly
local YouHatched = PetHatchedScreenUI.Frame.YouHatchedA
YouHatched.Text = "You Hatched A !!!"
Rarity.Text = "SkeletonFly"
PetName.Text = "Uncommon"
wait(2)
PetHatchedScreenUI.Enabled = false
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded
local hum = char.Humanoid
Camera.CameraSubject = hum
Rarity.Text = ""
PetName.Text = ""
YouHatched.Text = ""
local MagEript = game.Players.LocalPlayer.PlayerScripts.MagnitudeEggScript6
MagEript.Disabled = false
Pets.SkeletonFly.Parent = game.ReplicatedStorage.Pets.LavaWorldPets
local SkeletonFlyF = Instance.new("Folder")
SkeletonFlyF.Name = "SkeletonFly"
SkeletonFlyF.Parent = game.Players.LocalPlayer.PetsFolder
local EquippedValue = Instance.new("StringValue")
EquippedValue.Name = "EquippedValue"
EquippedValue.Value = "Unequipped"
EquippedValue.Parent = SkeletonFlyF
local DamageValue = Instance.new("IntValue")
DamageValue.Name = "DamageValue"
DamageValue.Value = 8717 *4.9
DamageValue.Parent = SkeletonFlyF
----------------------------------------------------------
local Storage = game.Players.LocalPlayer.PlayerGui.Storage
local template = Storage.template:Clone()
template.Name = "template"
local JungleCatF2 = Instance.new("Folder")
JungleCatF2.Name = "SkeletonFly"
JungleCatF2.Parent = template
local RarityValue2 = Instance.new("StringValue")
RarityValue2.Name = "Rarity"
RarityValue2.Value = "Uncommon"
RarityValue2.Parent = template
local DamageValue2 = Instance.new("IntValue")
DamageValue2.Name = "DamageValue"
DamageValue2.Value = 8717 *4.9
DamageValue2.Parent = template
local EquippedValue2 = Instance.new("StringValue")
EquippedValue2.Name = "EquippedValue"
EquippedValue2.Value = "Unequipped"
EquippedValue2.Parent = template
template.Parent = game.Players.LocalPlayer.PlayerGui.Inventory.LowerInvFrame.ScrollingFrame
elseif petChance >=81 and petChance <=95 then
PetHatchedScreenUI.Enabled = true
local Camera = game.Workspace.Camera
Pets.SpikeyBallon.Parent = PetViewPortFrame
PetViewPortFrame.CurrentCamera = game.Workspace.Camera
Camera.CameraSubject = Pets.SpikeyBallon
local YouHatched = PetHatchedScreenUI.Frame.YouHatchedA
YouHatched.Text = "You Hatched A !!!"
Rarity.Text = "SpikeyBallon"
PetName.Text = "Rare"
wait(2)
PetHatchedScreenUI.Enabled = false
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded
local hum = char.Humanoid
Camera.CameraSubject = hum
Rarity.Text = ""
PetName.Text = ""
YouHatched.Text = ""
local MagEript = game.Players.LocalPlayer.PlayerScripts.MagnitudeEggScript6
MagEript.Disabled = false
Pets.SpikeyBallon.Parent = game.ReplicatedStorage.Pets.LavaWorldPets
local SpikeBalloonF = Instance.new("Folder")
SpikeBalloonF.Name = "SpikelBallon"
SpikeBalloonF.Parent = game.Players.LocalPlayer.PetsFolder
local DamageValue = Instance.new("IntValue")
DamageValue.Name = "DamageValue"
DamageValue.Value = 23050 *4.9
DamageValue.Parent = SpikeBalloonF
local EquippedValue = Instance.new("StringValue")
EquippedValue.Name = "EquippedValue"
EquippedValue.Value = "Unequipped"
EquippedValue.Parent = SpikeBalloonF
----------------------------------------------------------
local Storage = game.Players.LocalPlayer.PlayerGui.Storage
local template = Storage.template:Clone()
template.Name = "template"
local JungleCatF2 = Instance.new("Folder")
JungleCatF2.Name = "SpikeyBalloon"
JungleCatF2.Parent = template
local RarityValue2 = Instance.new("StringValue")
RarityValue2.Name = "Rarity"
RarityValue2.Value = "Rare"
RarityValue2.Parent = template
local DamageValue2 = Instance.new("IntValue")
DamageValue2.Name = "DamageValue"
DamageValue2.Value = 23050*4.9
DamageValue2.Parent = template
local EquippedValue2 = Instance.new("StringValue")
EquippedValue2.Name = "EquippedValue"
EquippedValue2.Value = "Unequipped"
EquippedValue2.Parent = template
template.Parent = game.Players.LocalPlayer.PlayerGui.Inventory.LowerInvFrame.ScrollingFrame
elseif petChance >96 and petChance <=99 then
PetHatchedScreenUI.Enabled = true
local Camera = game.Workspace.Camera
Pets.LavaMonster.Parent = PetViewPortFrame
PetViewPortFrame.CurrentCamera = game.Workspace.Camera
Camera.CameraSubject = Pets.LavaMonster
local YouHatched = PetHatchedScreenUI.Frame.YouHatchedA
YouHatched.Text = "You Hatched A !!!"
Rarity.Text = "LavaMonster"
PetName.Text = "Epic"
wait(2)
PetHatchedScreenUI.Enabled = false
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded
local hum = char.Humanoid
Camera.CameraSubject = hum
Rarity.Text = ""
PetName.Text = ""
YouHatched.Text = ""
local MagEript = game.Players.LocalPlayer.PlayerScripts.MagnitudeEggScript6
MagEript.Disabled = false
Pets.LavaMonster.Parent = game.ReplicatedStorage.Pets.LavaWorldPets
local LavaMonsterF = Instance.new("Folder")
LavaMonsterF.Name = "LavaMonster"
LavaMonsterF.Parent = game.Players.LocalPlayer.PetsFolder
local DamageValue = Instance.new("IntValue")
DamageValue.Name = "DamageValue"
DamageValue.Value = 23050 *4.9*2
DamageValue.Parent = LavaMonsterF
local EquippedValue = Instance.new("StringValue")
EquippedValue.Name = "EquippedValue"
EquippedValue.Value = "Unequipped"
EquippedValue.Parent = LavaMonsterF
----------------------------------------------------------
local Storage = game.Players.LocalPlayer.PlayerGui.Storage
local template = Storage.template:Clone()
template.Name = "template"
local JungleCatF2 = Instance.new("Folder")
JungleCatF2.Name = "LavaMonster"
JungleCatF2.Parent = template
local RarityValue2 = Instance.new("StringValue")
RarityValue2.Name = "Rarity"
RarityValue2.Value = "Legendary"
RarityValue2.Parent = template
local DamageValue2 = Instance.new("IntValue")
DamageValue2.Name = "DamageValue"
DamageValue2.Value = 23050 *4.9*3
DamageValue2.Parent = template
local EquippedValue2 = Instance.new("StringValue")
EquippedValue2.Name = "EquippedValue"
EquippedValue2.Value = "Unequipped"
EquippedValue2.Parent = template
template.Parent = game.Players.LocalPlayer.PlayerGui.Inventory.LowerInvFrame.ScrollingFrame
end
end
PetPicker()
else
print("Player Can't Buy This Egg")
local EggErrorGui = game.Players.LocalPlayer.PlayerGui.EggErrorGui
EggErrorGui.Enabled = true
wait(5)
EggErrorGui.Enabled = false
end
end
end