Hi. I successfully made the bullet touched event ignore the local player and local player only, if anything else it will spawn a blackhole. Here’s the problem
What do you want to achieve? Keep it simple and clear!
The blackhole will suck everything that has humanoid and similarly to the bullet, i will ignore local player
What is the issue? Include screenshots / videos if possible!
The problem is that this time i have no way to get local player because the blackhole hasn’t cloned yet when the remote event fired
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve been researching this but nothing seems to work. Some suggest that using PlayerAdded event but still, the blackhole hasn’t there yet to detect
Any idea how to do this or another way to approach this?
(sorry if the post is too vague or verbose, this is my first post. Thanks in advance!)
There are a few ways. One being using Players.PlayerAdded
local Game = game
local Players = Game:GetService("Players")
Players.PlayerAdded:Connect(function(PlayerInstance)
-- PlayerInstance is our local player
end)
If your using touch then:
local Game = game
local Players = Game:GetService("Players")
local Part = -- Path to your part
Part.Touched:Connect(function(HitPart)
local Humanoid = HitPart.Parent:FindFirstChild("Humanoid") -- See if part is a part of a humanoid model
if Humanoid then
local PlayerInstance = Players:GetPlayerFromCharacter(Humanoid.Parent) -- We get our player
if PlayerInstance then
-- all your code belongs here
end
end
end)
For more knowledge about the Player service, please visit the official documentation.
This does work but it will get all players. I want the blackhole to ignore only the shooter, which is local player, that is why i’m trying to get local player here
Here is the code for the bullet i managed to filter the local player out
PassLocalPlayer is simply fired by a local script inside the tool when it is activated
AoE is the blackhole
local Desbris = game:GetService("Debris")
game.ReplicatedStorage.watersword.PassLocalPlayer.OnServerEvent:Connect(function(player)
script.Parent.Touched:Connect(function(hit)
if hit:IsDescendantOf(player.Character) or hit.Parent.Name == "AoE" then
else
--clone blackhole at the hit position
end
end)
end)
Here is the code for the blackhole
local Debris = game:GetService("Debris")
local hitbox = script.Parent.HitBoc
hitbox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and not hit.Parent:FindFirstChild("HumanoidRootPart"):FindFirstChild("BodyPosition") then
--Use BodyPosition in HumanoidRootPart
else
end
end)
script.Parent.Parent.Destroying:Connect(function()
BodyPosition:Destroy()
end)
You should add a tag to the bullet, that has the id of the person who fired it. When the bullet causes the black hole to be created, the black hole can read this tag, and understand which player to ignore.