local UserInputService = game:GetService("UserInputService")
local rs = game.ReplicatedStorage
local re = rs:WaitForChild("PetRE"):WaitForChild("PressingE")
UserInputService.InputBegan:Connect(function(input,gameProccesedEvent)
if input.KeyCode == Enum.KeyCode.E then
re:FireServer()
print("fired server")
end
end)
Second ServerScript:
local rs = game.ReplicatedStorage
local re = rs:WaitForChild("PetRE"):WaitForChild("PressingE")
local petModule = require(game.ServerScriptService:WaitForChild("PetModule"))
re.OnServerEvent:Connect(function(player)
if player.Stats.Crystal.Value >= 12000 and player.Stats.PetSpace.Value < 50 then
player.Stats.Crystal.Value = player.Stats.Crystal.Value - 12000
player.Stats.PetSpace.Value +=1
local pet = petModule.chooseRandomPet()
pet.UUID.Value = game.HttpService:GenerateGUID(true)
local petVal = Instance.new("StringValue")
petVal.Name = pet.Name
petVal.Parent = player.PetInventory
petVal.Value = pet.UUID.Value
print(player)--problem
game.ReplicatedStorage.PetRE.HatchEgg:FireClient(player,pet)
end
end)
The problem is that when I’m printing out the player, it prints out my name as many times as the number of players on the server. So it fires the client that many times. This is a part of my egg opening script, so the player opens as many eggs as the number of players on the server. I have no idea what the problem is, so help would be appreciated!
Im 90% sure this won’t do anything but its the only thing I can think of
local UserInputService = game:GetService("UserInputService")
local rs = game.ReplicatedStorage
local re = rs:WaitForChild("PetRE"):WaitForChild("PressingE")
local player = game:GetService("Players").LocalPlayer
UserInputService.InputBegan:Connect(function(input,gameProccesedEvent)
if input.KeyCode == Enum.KeyCode.E then
re:FireServer(player)
print("fired server")
end
end)
Okay, I get that but that still doesn’t explain the problem whatsoever. What exactly is going wrong and what is the intended behavior? What needs to do what? Please actually describe what’s going on so we can understand and help.
That won’t do anything, ROBLOX automatically passes the player sending the request to the connected function, passing it through manually won’t really fix anything.
Okay my bad. What is going wrong has already been said. The intented behaviour is that the player should only open 1 egg even if there are multiple players on the server. I don’t think there is more detail that needs to be said. Correct me if I’m wrong tho.
There absolutely does, you haven’t described anything about your system or where the scripts are, what they do, or even any console screenshots of your problem. We can’t help you when we have no idea what the problem is.