It basically says that the first argument has to be the player, which it is? Unless I'm wrong but I don't see how I could fix this?
Error: "FireClient: player argument must be a Player object?"
Serverscript In Tool
local Projectile = script.Parent local Heartbeat = game:GetService("RunService").Heartbeat while Heartbeat:wait() do Projectile.CFrame = CFrame.new(Projectile.Position, Projectile.Position + Projectile.Velocity) Projectile.Touched:connect(function(hit) local Player = game.Players:GetPlayerFromCharacter(hit.Parent) local Model = game.ReplicatedStorage.Morphs.SweetCheeks local Event = game.ReplicatedStorage.Events.Morph Event:FireClient(Player, Model) end) end
you shouldn't have a function inside a loop, since it will continuously create a new function when it really isn't necessary. you also need to have the Touched
event check if the part touching is an actual player so that it can fire.
fix:
local Projectile = script.Parent local Heartbeat = game:GetService("RunService").Heartbeat while Heartbeat:wait() do Projectile.CFrame = CFrame.new(Projectile.Position, Projectile.Position + Projectile.Velocity) end Projectile.Touched:Connect(function(hit) if hit and hit.Parent and hit.Parent:IsA('Model') and hit.Parent:FindFirstChild('Humanoid') then local Player = game:GetService('Players'):GetPlayerFromCharacter(hit.Parent) local Model = game:GetService('ReplicatedStorage').Morphs.SweetCheeks local Event = game:GetService('ReplicatedStorage').Events.Morph Event:FireClient(Player, Model) end end)
Morph Script
local event = game.ReplicatedStorage.Events.Morph event.OnServerEvent:Connect(function(player, model) print("--------") print("Player: "..player) print("--------") print("Morph: "..model) print("--------") local Char = model:Clone() local Pos = player.Character:GetPrimaryPartCFrame() local Schar = game.StarterPlayer:FindFirstChild("StarterCharacter") game:GetService("StarterPlayer") player.Character:Destroy() player.Character = Char Char.Parent = workspace local p = Char:Clone() p.Parent = game.StarterPlayer Char:SetPrimaryPartCFrame(Pos) Schar:Destroy() wait(30) end)
If your projectile system is working then you first need to check if it is a player or not.
local Projectile = script.Parent local Heartbeat = game:GetService("RunService").Heartbeat while Heartbeat:wait() do Projectile.CFrame = CFrame.new(Projectile.Position, Projectile.Position + Projectile.Velocity) Projectile.Touched:connect(function(hit) local Player = game.Players:GetPlayerFromCharacter(hit.Parent) if not Player then return nil end local Model = game.ReplicatedStorage.Morphs.SweetCheeks local Event = game.ReplicatedStorage.Events.Morph Event:FireClient(Player, Model) end) end
If the player variable wasn't an actual player, then the script will still run until there is an function, or property you want to change about the player. Or in all together anything that needs the player for some reason.
Sometimes functions return nil for a reason. They want to indicate that the following value isn't not found or returned.
If I didn't provide a right answer or it still does not work you can ask me