I'm still trying to figure out FireClient so imma need some help here. I have this script where when a player joins it copy's something in replicated Storage. Once it copies it It sends a Remote Event to the server which tells it to loop its BodyPosition to The Players Torso. But The arguments for some reason won't work. Here are my errors are
20:10:39.390 - Player is not a valid member of DataModel
Local Script
game.ReplicatedStorage.DoDun.OnClientEvent:Connect(function(Player,Part) local bp = Instance.new("BodyPosition") bp.Parent = Part bp.P = 20000 local Part = game.ReplicatedStorage["Creation Replicator"]:Clone() Part.Parent = workspace bp.Position = game.Player.Character.Torso.CFrame * CFrame.new(-2,0,0).Position wait() bp:Destroy() end)
Server Script
game.Players.PlayerAdded:Connect(function(Player) local Part = game.ReplicatedStorage["Creation Replicator"]:Clone() Part.Parent = workspace while true do wait() game.ReplicatedStorage.DoDun:FireClient(Part) end end)
Players
service is named Players
, not Player
. You also tried to fire a RemoteEvent
to a BasePart
, which will throw an error. You also do NOT pass the player in OnClientEvent
, as the server fires that remote, not the player. Simply just pass the Part
.local Players = game:GetService('Players') local Player = Players.LocalPlayer game.ReplicatedStorage.DoDun.OnClientEvent:Connect(function(Part) local bp = Instance.new("BodyPosition") bp.P = 20000 bp.Position = Player.Character:GetPrimaryPartCFrame() + CFrame.new(-2,0,0).p -- CFrame has no position property! it has a p tho! bp.Parent = Part -- parent last! wait() bp:Destroy() end)
-- Server! game.Players.PlayerAdded:Connect(function(Player) local Part = game.ReplicatedStorage["Creation Replicator"]:Clone() -- clone from only one or the other! there will be 2 parts if cloned from both! Part.Parent = workspace while true do wait() game.ReplicatedStorage.DoDun:FireClient(Player, Part) -- send player and part! end end)