local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local zone = require(game.ReplicatedFirst:WaitForChild("Zone"))
local bad = zone.new(workspace.Placing.Bad)
local placeRemote = game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("PlaceTower")
local runService = game:GetService("RunService")
local contextAction = game:GetService("ContextActionService")
local canPlace = true
local YOffset = 1.4
local maxDist = 25
local defender = game.ReplicatedStorage.Towers.Defender:Clone()
local Display = defender.Folder.Display
Display.Parent = workspace.Placing
defender.Parent = workspace.Placing
player.CharacterAppearanceLoaded:Wait()
mouse.TargetFilter = workspace.Placing
local trackedBad = bad:trackItem(defender.Folder.Hitbox)
local function pingServer(something, inputState)
if inputState == Enum.UserInputState.End and canPlace then
local magnitude = (player.Character.HumanoidRootPart.Position - defender.PrimaryPart.Position).magnitude
if magnitude <= maxDist then
local result = placeRemote:InvokeServer(defender:GetAttribute("ToPlace"), mouse.Hit.Position)
print(result)
end
end
end
contextAction:BindAction("Place Tower", pingServer, true, Enum.UserInputType.MouseButton1)
local function changeColor(tower, range, status)
local color
if status == true then
tower.Color.Value = true
color = BrickColor.new("Really red")
else
tower.Color.Value = false
color = BrickColor.new("Bright green")
end
for i,v in ipairs(tower:GetDescendants()) do
if v:IsA("BasePart") then
v.BrickColor = color
end
end
range.BrickColor = color
end
bad.itemEntered:Connect(function(trackedBad)
changeColor(defender, Display, true)
canPlace = false
end)
bad.itemExited:Connect(function(trackedBad)
changeColor(defender, Display, false)
canPlace = true
end)
runService.Heartbeat:Connect(function()
local mousePos = mouse.Hit.Position
local magnitude = (player.Character.HumanoidRootPart.Position - defender.PrimaryPart.Position).magnitude
defender:SetPrimaryPartCFrame(CFrame.new(mousePos.X, mousePos.Y + YOffset, mousePos.Z))
end)
I have a really strange issue. The above code was written in one game, which is a child of another game. To get to that game, I have to launch the parent game, then open asset manager, then I can finally launch the game this code is in. I don’t want to have to do this every time, so I thought what if I just publish this as a seperate game for easy access. The above code runs perfectly fine in game A, however in game B this doesn’t run at all, no errors whatsoever. What do I do?