I have a problem where I was trying to fire this event to change the camera but it isn’t firing, what is the problem?
Script 1
local cost = 500
local petModule = require(game.ServerScriptService.ModuleScripts:WaitForChild("PetModule"))
local RunService = game:GetService("RunService")
local HatchEgg = game.ReplicatedStorage.Events.HatchEgg
script.Parent.ClickDetector.MouseClick:Connect(function(player)
print(player.leaderstats.Diamonds.Value)
if player.leaderstats.Diamonds.Value >= cost then
player.leaderstats.Diamonds.Value = player.leaderstats.Diamonds.Value - cost
local pet = petModule.chooseRandomPet()
print(pet.Name.." selected")
HatchEgg:FireClient(player,pet)
end
end)
'Event Handler
local camera = game.Workspace.Camera
game.ReplicatedStorage.Events.HatchEgg.OnServerEvent:Connect(function(player,pet)
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = game.Workspace.CameraPart.CFrame
print("Hi")
I tried debugging this further and I got the same output.
19:56:30.831 0.5, 0.5 - Client
19:56:33.080 1000 - Server - Script:7
19:56:33.080 Bear selected - Server - Script:11
19:57:18.480 Disconnect from ::ffff:127.0.0.1|63659 - Studio
19:57:19.579 Data Has Been Saved - Server - Leaderboard:44
The player argument isn’t received by the callback function connected to the “.OnClientEvent” event only the additional arguments passed to the corresponding “:FireServer()” instance method call are.
Because this is a local script the local player instance can be quickly fetched/referenced via game.Players.LocalPlayer if necessary.