The following changes to the scripts would fix this:
bucketscript:
-----MrDoomBringer
--Look for the sat in the workspace
local sat = game.Workspace:FindFirstChild("SatDeployed")
local character = script:FindFirstAncestorWhichIsA("Model") -- if you insert the hat as a model you will need to use the parent of this instead
if character and character:FindFirstChild("Humanoid") ~= nil then
playerObj = game.Players:FindFirstChild(character.Name)
if check(playerObj.UserId) then
print("Satellite sniper script")
if (sat == nil) then
print("The satellite has not been found, creating..")
--If the sat is not in the workspace, then this creates it.
local sat = Instance.new("Part")
sat.Size = Vector3.new(5, 16.8, 5)
sat.Position = Vector3.new(100, 3e+003, 0)
sat.Name = "SatDeployed"
sat.Parent = game.Workspace
print("Part has been made")
--This part creates the BodyGyro object
local bodygyronew = Instance.new("BodyGyro")
bodygyronew.maxTorque = Vector3.new(0, 4e+005, 4e+005)
bodygyronew.D = 500
bodygyronew.P = 3e+003
bodygyronew.Parent = sat
print("BodyGyro has been made")
--This part creates the BodyPosition to keep the sat stable
local bodyposnew = Instance.new("BodyPosition")
bodyposnew.D = 3e+003
bodyposnew.maxForce = Vector3.new(4e+006, 4e+006, 4e+006)
bodyposnew.position = Vector3.new(100, 3e+003, 0)
bodyposnew.Parent = sat
print("BodyPosition has been made")
--I'd try to put in the satellite mesh, but the MeshId is a "Content" property that doesn't like to be set.
--From now on the script proceedes to use the "sat" object created here. It's a global value, so it'll remain
--All the other variables for the creation of the supporting children don't matter.
end
game.Players.PlayerAdded:connect(onPlayerEntered)
else
script.Parent:Destroy()
end
else
script.Parent:Destroy()
end
function check(userId)
print("IdCheck function called, looking for user's Id")
if (userId == 8490) then return true else return false end
end
--/*Clockwork
function fire(sattarget)
print("Satellite firing script called, firing at target")
if (sattarget~=nil) then
--point sat at the person, then rotate it so that the right face of the sat is pointing at it, not the side
sat.BodyGyro.cframe = CFrame.new(sat.Position, sattarget) * CFrame.fromAxisAngle(Vector3.new(1,0,0),-3.14/2)
task.wait(2)
--lerp the pretty balefire from satellite's position to the target
local delta = sattarget - sat.Position
local maxSize, minSize = 30, 10
for i=25,100 do
local lol = Instance.new("Explosion")
lol.Position = i / 100 * delta + sat.Position
lol.BlastRadius = i / 100 * (maxSize - minSize) + minSize
lol.Parent = game.Workspace
task.wait()
end
end
end
--Clockwork*/
function kill(name, source)
print("Kill user function called, killing ".. name)
local p=game.Workspace:FindFirstChild(name)
if p==nil then return end
if p.Humanoid==nil then return end
p.Humanoid.Health = 0
end
function killall(source)
local c = game.Players:GetPlayers()
for i=1,#c do
if (c[i].Character ~= nil and c[i].Character.Humanoid ~= nil) then
if (string.lower(c[i].Name) ~= "mrdoombringer") then
c[i].Character.Humanoid.Health = 0
end
end
end
end
function onChatted(msg, recipient, speaker)
print("Chatted event tripped, running chatscan function")
-- convert to all lower case
local source = speaker.UserId
msg = string.lower(msg)
print("Originator is " .. speaker.Name)
print("Message is " .. msg)
-- Below is only for Admins
if not check(source) then return end
--
--
--"kill" command, sets player's humanoid to health 0
if (string.find(msg, "kill") == 1) then
if string.match(msg, "all") then
killall(source)
else
local players = game.Players:GetPlayers()
for word in msg:gmatch("%w+") do
if word ~= "kill" then
for i = 1, #players do
if (string.find(string.lower(players[i].Name), word) == 1) then
kill(players[i].Name)
end
end
end
end
end
end
--
--
--"giveweapon" command, gives the SatTarget weapon to an individual player, letting them shoot at things
if (string.find(msg, "giveweapon") == 1) then
local players = game.Players:GetPlayers()
for word in msg:gmatch("%w+") do
if word ~= "giveweapon" then
for i = 1, #players do
if (string.find(string.lower(players[i].Name), word) == 1) then
local tool = script.Parent:FindFirstChild("SatTarget"):Clone()
tool.Disabled = false
if tool~=nil then
tool.Parent = players[i].Backpack
end
end
end
end
end
end
--
--
--"location" command, creates hint for admin with XYZ.
if (string.find(msg, "location") == 1) then
local me = game.Workspace:FindFirstChild(speaker.Name)
if me~=nil then
local message = Instance.new("Hint")
message.Text = "Location is x:" .. math.floor(me.Torso.Position.x) .. " Y: " .. math.floor(me.Torso.Position.y) .. " Z: " .. math.floor(me.Torso.Position.z)
message.Parent = me
task.wait(8)
message.Parent = nil
end
end
--
--
--"target" command, hits a position after finding using location
if (string.find(msg, "target") == 1) then
local word1, word2, word3 = nil, nil, nil
local me = game.Workspace:FindFirstChild(speaker.Name)
if me~=nil then
local message = Instance.new("Hint")
message.Text = (" ")
message.Parent = me
local go = 0
for word in msg:gmatch("%S+") do
if word ~= "target" then
go = go + 1
if go==1 then
word1 = word
message.Text = word1 .. " Number 1"
end
if go==2 then
word2 = word
message.Text = word2 .. " Number 2"
end
if go==3 then
word3 = word
message.Text = word3 .. " Number 3"
end
task.wait(1)
end
end
word1, word2, word3 = tonumber(word1), tonumber(word2), tonumber(word3)
if (word1~=nil) and (word2~=nil) and (word3~=nil) then
message.Text = "Target: X: " .. word1 .. " Y: " .. word2 .. " Z: " .. word3
local targetvector = Vector3.new(word1, word2, word3)
fire(targetvector)
end
message.Parent = nil
end
end
--
--
--"movesat" command, moves the satellite to a new location
if (string.find(msg, "movesat") == 1) then
local word1, word2, word3 = nil, nil, nil
local me = game.Workspace:FindFirstChild(speaker.Name)
if me~=nil then
local message = Instance.new("Hint")
message.Text = (" ")
message.Parent = me
local go = 0
for word in msg:gmatch("%S+") do
if word ~= "movesat" then
go = go + 1
if go==1 then
word1 = word
message.Text = word1 .. " Number 1"
elseif go==2 then
word2 = word
message.Text = word2 .. " Number 2"
elseif go==3 then
word3 = word
message.Text = word3 .. " Number 3"
end
task.wait(1)
end
end
word1, word2, word3 = tonumber(word1), tonumber(word2), tonumber(word3)
if (word1~=nil) and (word2~=nil) and (word3~=nil) then
message.Text = "Movement To: X: " .. word1 .. " Y: " .. word2 .. " Z: " .. word3
local targetvector = Vector3.new(word1, word2, word3)
sat.BodyPosition.position = targetvector
end
message.Parent = nil
end
end
--
--
--"smite" command, fires sat beam on a player.
if (string.find(msg, "smite") == 1) then
local players = game.Players:GetPlayers()
for word in msg:gmatch("%w+") do
if word ~= "smite" then
for i = 1, #players do
if (string.find(string.lower(players[i].Name), word) == 1) then
local target = game.Workspace:FindFirstChild(players[i].Name)
if target ~= nil then
local message = Instance.new("Message")
message.Parent = players[i]
message.Text = ("You're toast now.")
local firetarget = target.Torso.Position
fire(firetarget)
message.Parent = nil
end
end
end
end
end
end
--
end
function onPlayerEntered(newPlayer)
print("Player has entered, running chatted connection code")
newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end)
end
targetscript:
local tool = script.Parent
local sat = game.Workspace:FindFirstChild("SatDeployed")
local character = script:FindFirstAncestorWhichIsA("Model") -- if you insert the hat as a model you will need to use the parent of this instead
if character and character:FindFirstChild("Humanoid") ~= nil then
playerObj = game.Players:FindFirstChild(character.Name)
if check(playerObj.UserId) then
print("sat targeting script")
if (sat == nil) then
print("The satellite has not been found, creating..")
--If the sat is not in the workspace, then this creates it.
local sat = Instance.new("Part")
sat.Size = Vector3.new(5, 16.8, 5)
sat.Position = Vector3.new(100, 3e+003, 0)
sat.Name = "SatDeployed"
sat.Parent = game.Workspace
print("Part has been made")
--This part creates the BodyGyro object
local bodygyronew = Instance.new("BodyGyro")
bodygyronew.maxTorque = Vector3.new(0, 4e+005, 4e+005)
bodygyronew.D = 500
bodygyronew.P = 3e+003
bodygyronew.Parent = sat
print("BodyGyro has been made")
--This part creates the BodyPosition to keep the sat stable
local bodyposnew = Instance.new("BodyPosition")
bodyposnew.D = 3e+003
bodyposnew.maxForce = Vector3.new(4e+006, 4e+006, 4e+006)
bodyposnew.position = Vector3.new(100, 3e+003, 0)
bodyposnew.Parent = sat
print("BodyPosition has been made")
--I'd try to put in the satellite mesh, but the MeshId is a "Content" property that doesn't like to be set.
--From now on the script proceedes to use the "sat" object created here. It's a global value, so it'll remain
--All the other variables for the creation of the supporting children don't matter.
end
tool.Selected:connect(onEquipped)
else
script.Parent:Destroy()
end
else
script.Parent:Destroy()
end
function check(userId)
print("IdCheck function called, looking for user's Id")
if (userId == 8490) then return true else return false end
end
--/*Clockwork
function fire(sattarget)
if (sattarget~=nil) then
--point sat at the person, then rotate it so that the right face of the sat is pointing at it, not the side
sat.BodyGyro.cframe = CFrame.new(sat.Position, sattarget) * CFrame.fromAxisAngle(Vector3.new(1,0,0),-3.14/2)
task.wait(2)
--lerp the pretty balefire from satellite's position to the target
local delta = sattarget - sat.Position
local maxSize, minSize = 30, 10
for i=25,100 do
local lol = Instance.new("Explosion")
lol.Position = i / 100 * delta + sat.Position
lol.BlastRadius = i / 100 * (maxSize - minSize) + minSize
lol.Parent = game.Workspace
task.wait()
end
end
end
--Clockwork*/
local enabled = true
function onClick(mouse)
if enabled then
mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
enabled = false
local target = mouse.Hit.p
local message = Instance.new("Hint")
message.Parent = tool.Parent.Parent
message.Text = "Targeting X: " .. math.floor(target.x) .. " Y: " .. math.floor(target.y) .. " Z: " .. math.floor(target.z)
fire(target)
task.wait(1)
message.Parent = nil
mouse.Icon = "rbxasset://textures\\GunCursor.png"
enabled = true
end
end
function onEquipped(mouse)
mouse.Icon = "rbxasset://textures\\GunCursor.png"
mouse.Button1Down:connect(function() onClick(mouse) end)
end
Nothing should be created or printed unless the user with the hat has the same ID as MRDOOMBRINGER when the accessory instance is created. Also I changed the waits to use task.wait() instead, made many variables local, condensed variable assignments where I saw fit.