My tool that places a shield doesn't work. The output shows no relative error whatsoever. It works in Studio, but not the in game. I have tried switching it from a script, to a localscript, but that only caused irrelevant errors (ServerStorage is not a valid member of DataModel(game)). Here is my code:
tool = script.Parent
db = true
r = 0
angle = 0
eq = false
player = tool.Parent.Parent
tool.Equipped:connect(function(mouse)
eq = true
mouse.Icon = "rbxasset://textures\\GunCursor.png"
mouse.Button1Down:connect(function()
if db and eq then
db = false
tool.Name = "[Shield; " .. angle .. "; Recharging]"
mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
local torso = tool.Parent:FindFirstChild("Torso")
local shield = game.ServerStorage.Shield:Clone()
shield.Parent = game.Workspace
shield.Name = "Shield" .. r
r = r + 1
shield:SetPrimaryPartCFrame(CFrame.new(torso.CFrame.x, torso.CFrame.y - 3, torso.CFrame.z + 3) * CFrame.Angles(0, angle, 0) )
game:GetService("Debris"):AddItem(game.Workspace:FindFirstChild(shield.Name), 60)
wait(120)
db = true
tool.Name = "[Shield; ".. angle .. "; Ready]"
mouse.Icon = "rbxaset://textures\\GunCursor.png"
end
mouse.KeyDown:connect(function(key)
if key == "r" and db then
if angle == 0 then
angle = 90
elseif angle == 90 then
angle = 180
elseif angle == 180 then
angle = 0
end
tool.Name = "[Shield; " .. angle .. "; Ready]"
end
end)
end)
end)
tool.Unequipped:connect(function()
eq = false
end)
Please help. (As far as I know,) There is absolutely no reason for it to not work.
