For some reason my remote event fires fine with other scripts besides the current one I am using, I tried other scripts and it worked fine I also tried created multiple copy scripts to see if it worked and no luck. Can I get some help debugging this?
The bottom is where the remote event should be received but it doesn't pick up the event being fired, and yes I checked everything over multiple times but it still won't pick up the signal.
Also, the script is in ServerScriptService and I tried putting it in other places but got the same result.
for i,v in pairs(game.Players:GetChildren()) do
local RS = game:GetService("ReplicatedStorage")
local Library = RS:WaitForChild("PetLibrary")
local Eggs = require(Library:WaitForChild("Config"))
local Data = Eggs[v.PlayerGui.Eggs.Items.ItemHandler.ItemName.Text]
local Cost = Data["Cost"]
local Pets = Data["Pets"]
local Event = RS:WaitForChild("EggOpen")
local MaxPetsAllowed = 100 -- just for testing!
local function TweenCoord(Obj,coord)
local TS = game:GetService("TweenService")
local TI = TweenInfo.new(.1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut)
local properties = {
CFrame = coord
}
local Tween = TS:Create(Obj,TI,properties)
Tween:Play()
end
local Library = Library[v.PlayerGui.Eggs.Items.ItemHandler.ItemName.Text]
local function ChoosePet()
local TotalWeight = 0
for i,v in pairs(Pets) do
TotalWeight = TotalWeight + v[1]
end
local Chance = math.random(1,TotalWeight)
local Counter = 0
for i,v in pairs(Pets) do
Counter = Counter+v[1]
if Chance <= Counter then
return i
end
end
end
local function UnBox(Player)
local stats = Player:WaitForChild("leaderstats")
local coins = stats:WaitForChild("Coins")
if coins.Value >= Cost then
local PetInv = Player:WaitForChild("Pets")
local Counter = 0
for i,v in pairs(PetInv:GetChildren()) do
Counter = Counter + 1
end
if Counter >= MaxPetsAllowed then
local GUI = Instance.new("ScreenGui")
local TextLabel = Instance.new("TextLabel")
TextLabel.Position = UDim2.new(0,0,.7,0)
TextLabel.Size = UDim2.new(1,0,.2,0)
TextLabel.BackgroundTransparency = 1
TextLabel.TextScaled = true
TextLabel.TextSize = 1
TextLabel.Font = Enum.Font.Cartoon
TextLabel.TextStrokeTransparency = 0
TextLabel.TextColor3 = Color3.fromRGB(0,55,200)
TextLabel.Text = "Inventory Full!"
TextLabel.Parent = GUI
GUI.Parent = Player.PlayerGui
wait(3)
GUI:Destroy()
else
coins.Value = coins.Value - Cost
local PetChosen = ChoosePet()
local Pet = Library:WaitForChild(PetChosen):Clone()
Pet.Parent = PetInv
local coord
local GUI = Instance.new("ScreenGui")
local GUIPet = Library:WaitForChild(PetChosen):Clone()
local PetPos = GUIPet.PrimaryPart.Position
local Viewport = Instance.new("ViewportFrame")
local Text = Instance.new("TextLabel")
Text.TextScaled = true
Text.TextColor3 = Color3.fromRGB(255,255,255)
Text.BackgroundTransparency = 1
Text.Size = UDim2.new(0.4,0,0.1,0)
Text.Position = UDim2.new(0.3,0,0.65,0)
Text.Font = Enum.Font.SourceSansSemibold
Viewport.Size = UDim2.new(1,0,1,0)
Viewport.BackgroundTransparency = 1
local Camera = Instance.new("Camera")
Camera.Parent = workspace
Viewport.CurrentCamera = Camera
local PetCamera = game.Workspace.Camera
local Egg = Player.PlayerGui.Eggs.Items.Items[Player.PlayerGui.Eggs.Items.ItemHandler.ItemName.Text]:Clone()
local EggPos = Egg.PrimaryPart.Position
Egg.Parent = Viewport
Camera.CFrame = CFrame.new(Vector3.new(EggPos.X,EggPos.Y,EggPos.Z+Egg.PrimaryPart.Size.X+7),EggPos)
coord = Camera.CFrame
Viewport.Parent = GUI
Viewport.Position = UDim2.new(0,0,-1,0)
GUI.Parent = Player.PlayerGui
Viewport:TweenPosition(UDim2.new(0,0,0,0),"Out","Quad",0.30,false)
wait(0.2)
wait(0.5)
for i = 1,5 do
TweenCoord(Camera,coord*CFrame.Angles(0,0,.6))
wait(.1)
TweenCoord(Camera,coord*CFrame.Angles(0,0,-.6))
wait(.1)
end
TweenCoord(Camera,coord)
wait(0.05)
for i = 1,7 do
TweenCoord(Camera,coord*CFrame.Angles(0,0,.6))
wait(.05)
TweenCoord(Camera,coord*CFrame.Angles(0,0,-.6))
wait(.05)
end
TweenCoord(Camera,coord)
wait(0.25)
Egg:Destroy()
Viewport.CurrentCamera = PetCamera
GUIPet.PrimaryPart.Size = Vector3.new(0.5,0.5,0.5)
Text.Text = GUIPet.Name
Text.Parent = GUI
GUIPet.Parent = Viewport
wait(3)
Viewport:TweenPosition(UDim2.new(0,0,1,0),"Out","Quad",0.25,false)
Text:TweenPosition(UDim2.new(0.3,0,1.65,0),"Out","Quad",0.25,false)
wait(0.25)
GUI:Destroy()
end
else
local GUI = Instance.new("ScreenGui")
local TextLabel = Instance.new("TextLabel")
TextLabel.Position = UDim2.new(0,0,.7,0)
TextLabel.Size = UDim2.new(1,0,.2,0)
TextLabel.BackgroundTransparency = 1
TextLabel.TextScaled = true
TextLabel.TextSize = 1
TextLabel.Font = Enum.Font.Cartoon
TextLabel.TextStrokeTransparency = 0
TextLabel.TextColor3 = Color3.fromRGB(255,0,0)
TextLabel.Text = "Not Enough Coins!"
TextLabel.Parent = GUI
GUI.Parent = Player.PlayerGui
wait(3)
GUI:Destroy()
end
end
Event.OnServerEvent:Connect(function(player)
print("Received")
if player:FindFirstChild("GettingPet") then return end
local debounce = Instance.new("BoolValue")
debounce.Name = "GettingPet"
debounce.Parent = player
UnBox(player)
debounce:Destroy()
end)
end
