Note: I am not 100% sure if this is in the right category so please tell me if it is not.
Hello All,
So I am making a game with a ball that you through and If someone touches it they have the ball (kinda like hot potato). The ball is shooting out fine, but the touch interest is not appearing. I feel like I am doing something dumb. I even tried cloning a ball with working touch interest from workspace, but the touch interest just disappeared.
This is the script:
local DebrisService = game:GetService("Debris")
local PlayersService = game:GetService("Players")
local Player = PlayersService.LocalPlayer
local Tool = script.Parent
local ToolHandle = Tool:WaitForChild("Handle")
local Gravity = 90
local ThrowSpeed = 90
local ReloadTime = 1.75
local Lifetime = 50
local ThrowedRock = game.Workspace.DemoBall
local bodyForce = Instance.new('BodyForce',ThrowedRock)
bodyForce.Name = 'ThrowForce'
bodyForce.force = Vector3.new(0, ThrowedRock:GetMass() * Gravity, 0)
function OnActivated()
local Character = Player.Character
if Tool.Enabled and Character and Character:FindFirstChild('Humanoid') and Character.Humanoid.Health > 0 then
Tool.Enabled = false
local ThrowedRockClone = ThrowedRock:Clone()
--DebrisService:AddItem(ThrowedRockClone,Lifetime)
local Rock_Spawn_Position = (ToolHandle.CFrame * CFrame.new(0, 0, 2.25)).p
ThrowedRockClone.CFrame = CFrame.new(Rock_Spawn_Position, Character.Humanoid.TargetPoint)
ThrowedRockClone.Velocity = ThrowedRockClone.CFrame.lookVector * ThrowSpeed
ThrowedRockClone.Parent = game.Workspace
wait(ReloadTime)
Tool.Enabled = true
end
end
Tool.Activated:connect(OnActivated)
TouchTransmitter instances are automatically created providing the BasePart instance can be touched and some script has a Touched event listener for the aforementioned BasePart (you don’t need to clone a BasePart instance with one inside).
local DebrisService = game:GetService("Debris")
local PlayersService = game:GetService("Players")
local Player = PlayersService.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Tool = script.Parent
local ToolHandle = Tool:WaitForChild("Handle")
local Gravity = 90
local ThrowSpeed = 90
local ReloadTime = 1.75
local Lifetime = 50
local ThrowedRock = workspace:WaitForChild("DemoBall")
local BodyForce = Instance.new("BodyForce")
BodyForce.Parent = ThrowedRock
BodyForce.Name = "ThrowForce"
BodyForce.force = Vector3.new(0, ThrowedRock:GetMass() * Gravity, 0)
function OnActivated()
if Tool.Enabled and Character and Character:FindFirstChild('Humanoid') and Character.Humanoid.Health > 0 then
Tool.Enabled = false
local ThrowedRockClone = ThrowedRock:Clone()
--DebrisService:AddItem(ThrowedRockClone,Lifetime)
local Rock_Spawn_Position = (ToolHandle.CFrame * CFrame.new(0, 0, 2.25)).p
ThrowedRockClone.CFrame = CFrame.new(Rock_Spawn_Position, Humanoid.TargetPoint)
ThrowedRockClone.Velocity = ThrowedRockClone.CFrame.lookVector * ThrowSpeed
ThrowedRockClone.Parent = game.Workspace
task.wait(ReloadTime)
Tool.Enabled = true
end
end
Tool.Activated:connect(OnActivated)
I have already tried that, the ball that is in workspace when I test it has touch interest as a child, but when it is cloned it loses that touch interest. I am very confused right now
It is all good, I managed to use a replica ball that I welded to the ball in the script, which isn’t cloned meaning it keeps its touch interest. Not the most efficient way, but it works . Thanks for all the help anyways.