I really don't know how to spawn a forcefield in, but what is blocking me is how do I find a character in a script. (not local script)
Tool = script.Parent local event = game.ReplicatedStorage local Players = game:GetService("Players") local character = Players.Character or Players.CharacterAdded:wait() event.Block.OnServerEvent:connect(function(plr) local forceField = Instance.new("ForceField") forceField.Visible = true forceField.Parent = character wait(.5) forceField:remove() end)
You can easily get a player's character through the Character property of the player. Since you're using a remoteevent, you already have a player, so all you need to do is get the Character.
Tool = script.Parent local event = game.ReplicatedStorage local Players = game:GetService("Players") event.Block.OnServerEvent:connect(function(plr) local character = plr.Character local forceField = Instance.new("ForceField") forceField.Visible = true forceField.Parent = character wait(.5) forceField:Destroy() -- Apparently :remove() is deprecated, use :Destroy() instead for getting rid of things. end)
You cannot do player.Character, even if you have the player object, on the server. My best option is just finding the character in workspace using the player's name.
Tool = script.Parent local event = game.ReplicatedStorage local Players = game:GetService("Players") event.Block.OnServerEvent:connect(function(plr) local character = game.Workspace:WaitForChild(plr.Name) -- will look in workspace for an object wich has the players name, wich is their character local forceField = Instance.new("ForceField") forceField.Visible = true forceField.Parent = character wait(.5) forceField:remove() end)
Hope this solved your problem!