hitparts.Touched:Connect(function(Hit)
local Character = Hit.Parent
local Player = game:GetService("Players"):GetPlayerFromCharacter(Character)
if Player and Player.Team.Name == "Blue" then
ball.CFrame = CFrame.new(opart.Position)
warn("Teleported Ball!")
end
end)
Nothing happened-------------------------
Could you show me console?
Using the Print I found that the script is not reliacing I am on the blue team and
hitparts.Touched:Connect(function(hit)
local character = hitparts.Parent
local player = game.Players:GetPlayerFromCharacter(character)
if player and player.TeamColor == BrickColor.new("Really blue") then
ball.CFrame = CFrame.new(opart.Position)
else
ball.CFrame = CFrame.new(bpart.Position)
end
end)
Thes make the ball go to the other part but not the right part
This is incorrect, thats why it doesnt work, change it to hit.Parent
That did not work--------------------
I have re-structured the entire script with a different methodology, which should hopefully resolve your issue.
local ball = workspace:WaitForChild("Ball")
local hitparts = script.Parent.Tool.Handle -- change the path to your tool.handle
local character = script.Parent
local opart = workspace:WaitForChild("O")
function checkIntersection()
local ballBB = workspace:GetPartsInPartBounds(ball.Size, ball.CFrame)
for _, part in ipairs(ballBB) do
if part == hitparts and game.Players:GetPlayerFromCharacter(character).TeamColor == BrickColor.new("Really blue") then
ball.CFrame = opart.CFrame
break
end
end
end
while true do
wait(0.1) -- Adjust the time as necessary
checkIntersection()
end
Although, you need to do some stuff:
- Place this script within
StarterCharacterScripts
. - Adjust the path to
hitparts
based on where your tool is parented - I’ve made an educated guess, but it might need tweaking. - After making these adjustments, test the script and let me know if it performs to your expectations or if further refinements are needed.
1 Like
I updated my reply, it should work now.