What I am trying to achieve?
When the chant is fully played the players around the caster will be detected by touched and then I weld constraint them to the hitbox then move them to another dimension same goes for the caster.After moving them the explosion will deal 80 damage to the players that are in the dimension other than the caster by using another touched connect.After that I will move the hitbox that the players are welded constraint back to the original position.
(Table would be useful instead of using this inefficient way.)
Issue:
Sometimes the players that are teleported to the dimension will not get damage.
I think it could be weld constraint,when they are welded they wont get damage?
When they do get damage,they die.My touched script should had prevented from damaging players that already been damaged.
Welding players to the hitbox script:
local Hits = {}
hitbox.Touched:Connect(function(Hit)
if Hits[Hit.Parent.Name] then
return
end
if Hit.Parent:FindFirstChild(âIframesâ) then
return
end
if Hit.Parent.Name == player.Name then return end
Hits[Hit.Parent.Name] = true
local StunHandler = require(game.ReplicatedStorage.StunHandlerV2)
StunHandler.Stun(Hit.Parent.Humanoid, 38.7, Hit.Parent.CanAttack)
local stun = game.ReplicatedStorage.ExtraFolder.StunnedBillBoard:Clone()
stun.Parent = Hit.Parent.Head
game.Debris:AddItem(stun,38.7)--change-->> stuns for 5 seconds
local stick = Instance.new("WeldConstraint",hitbox)
stick.Part0 = hitbox
stick.Part1 = Hit.Parent.HumanoidRootPart
game.Debris:AddItem(stick,40)
end)
Damaging Part when players teleported to the dimension:
local Hits = {}
part1.Touched:Connect(function(Hit)
if Hits[Hit.Parent.Name] then
return
end
if Hit.Parent:FindFirstChild(âIframesâ) then
return
end
Hits[Hit.Parent.Name] = true
Hit.Parent.Humanoid:TakeDamage(20)
local stick = Instance.new("WeldConstraint",player.Character:FindFirstChild("CoverMarble"))
stick.Part0 = player.Character:FindFirstChild("CoverMarble")
stick.Part1 = Hit.Parent.HumanoidRootPart
end)
From what I know from testing multiple times,when the touch does work the players wont be brought out of the dimension.But when the players didnt receive the damage they will get teleported out of the dimension.The code itself is really inconsistence.
To be honest I dont really know how to use table and I am pretty sure for the teleporting back out of the dimension can use tables but I dont know how.Its indeed much efficient than the way I am using right now.
File too big so I had no choice(I was struggling to go to the dimension map in the video so bare with me lol)
Edited
I found few lines of codes for teleporting back with a table but the problem it applies to all players in game not those nearby the caster of the move.When teleporting back it also applies to all players not the ones being affected by the move.
local playerLocations = {}
local PlayerService = game:GetService(âPlayersâ)
for _, player in pairs(PlayerService:GetPlayers()) do
playerLocations[player] = player.Character:GetPrimaryPartCFrame()
end
for _, player in pairs(PlayerService:GetPlayers()) do
player.Character:SetPrimaryPartCFrame(playerLocations[player])
end
Maybe someone can help me or teach me how do I save the playersâ position around the caster in a table then after a certain time the players will be teleported back to the saved position in the table.(Make sure its not all players only the ones that are close by the caster.)