-
What do you want to achieve?
I want to make a tool that when clicked will create a part that looks like lightning and will deal damage to everybody except the person who made that part (The person using the tool) if they touch / make contact with it. -
What is the issue?
Due to the part being made on the server, I couldn’t get the local player to check if the person who touches it is the person who made it or not. -
What solutions have you tried so far?
I have searched to see if there is a way to bring the local player from a local script to a server script but I have been left confused or without an answer. Also some of the methods haven’t worked for me.
Local script: (Inside of a tool which is inside of “StarterPack”)
local repStorage = game:GetService("ReplicatedStorage")
local event = repStorage.LightningEvent
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local toolDeb = false
local CD = 1 --Cooldown
local tool = script.Parent
tool.Activated:Connect(function()
if not toolDeb then
toolDeb = true
local pos = mouse.Hit.Position
event:FireServer(pos)
task.wait(CD)
toolDeb = false
end
end)
Server script: (Inside of “ServerScriptService”)
local repStorage = game:GetService("ReplicatedStorage")
local debris = game:GetService("Debris")
local event = repStorage.LightningEvent
event.OnServerEvent:Connect(function(player, pos)
local humanoid = player.Character:WaitForChild("Humanoid")
local part = Instance.new("Part", workspace)
part.BrickColor = BrickColor.new("New Yeller")
part.Material = Enum.Material.Neon
part.Transparency = 0.2
part.Anchored = true
part.CanCollide = false
part.CastShadow = false
part.Position = pos
part.Size = Vector3.new(2, 200, 2)
debris:AddItem(part, 1.2)
end)
All help is appreciated! Thanks in advance.
-Kotium