Hi everyone,
I’m creating a marble tag-style game. My current code to tag another user works once, but then it stops working with no errors. I have tested with a part that should work with the code AND another client. Does not work either way.
code:
“ballgamescript”:
print("ballgamescript loaded")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
_G.isTag = true
local HRP = char:WaitForChild("HumanoidRootPart")
local marble = Instance.new("Part")
marble.Name = "marblehit"
marble.Size = Vector3.new(10,10,10)
marble.Transparency = .5
marble.Shape = Enum.PartType.Ball
marble.Parent = char
marble.Material = Enum.Material.SmoothPlastic
local Velocity = Instance.new("BodyAngularVelocity")
Velocity.Parent = marble
local Hum = char:WaitForChild("Humanoid")
local Weld = Instance.new("Weld")
Weld.Parent = marble
Weld.Part0 = HRP
Weld.Part1 = marble
Hum.PlatformStand = true
while true do
wait()
marble.BodyAngularVelocity.AngularVelocity = Vector3.new(char.Humanoid.MoveDirection.z * 32,0,char.Humanoid.MoveDirection.x * -32)
marble.BodyAngularVelocity.MaxTorque = Vector3.new(10000,10000,10000)
if char.Humanoid.MoveDirection == Vector3.new(0,0,0) then
marble.BodyAngularVelocity.MaxTorque = Vector3.new(0,0,0)
end
end
if _G.isTag == true then
marble.BrickColor = BrickColor.new("Black")
else
marble.BrickColor = BrickColor.Random()
end
end)
end)
“tagscript”
print("tag loaded")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("marblehit").Touched:Connect(function(hit)
if hit:IsA("Part") and hit.Name == "marblehit" then
if _G.isTag == true then
hit.BrickColor = BrickColor.new("Black")
_G.isTag = false
character:WaitForChild("marblehit").BrickColor = BrickColor.Random()
end
end
end)
end)
end)
output:
16:22:51.349 Bubble Bombs tech demo @ 17 Oct 2022 16:22 auto-recovery file was created - Studio
16:22:53.076 ballgamescript loaded - Server - bgsdemo:1
16:22:53.076 tag loaded - Server - tagdemo:1
16:22:55.121 Requiring asset 512742721.
Callstack:
cloud_8428896693.archimedesTwo.initiatePlugin.MainModule, line 29
cloud_8428896693.archimedesTwo.initiatePlugin.MainModule, line 28
- Server
16:22:55.164 initialized - Server
16:22:55.338 Requiring asset 518094091.
Callstack: