I have two different scripts which are tied together, one for a certain appearance of the object upon click, the second for the damage of the object when it collides with another player. The scripts are old and updated a quite a while ago; I've done a few tweaks and it's coming closer and closer to finished, however there are still two issues at hand.

The tool itself and its defining script for its size is kept in Lighting and is given to the player upon clicking a button in a GUI. The second portion containing the damage element is in ReplicatedStorage.

**1. ** The projectile made upon click will appear on the screen of whoever uses it, but will not appear on the screen of a 2nd player. 2. The projectile, seemingly because it cannot be seen by any players except the user, does no damage. The damage portion of the tool is kept in ReplicatedStorage.

Tool Script:

bin = script.Parent
me = script.Parent.Parent.Parent

enabled = true

function onButton1Down(mouse)
if not enabled then
		return
	end

	local player = game.Players.LocalPlayer
	if player == nil then return end
        enabled = false


	mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"

wait(0.5)

for i = 1 , 15 do
local p = Instance.new("Part")
p.Parent = game.Workspace
p.CanCollide = false
p.Size = Vector3.new(math.random(1,2),math.random(1,2),math.random(1,2))
p.BrickColor = BrickColor.new("Bright blue")
p.Transparency = 0.6
p.TopSurface = "Smooth"
p.BottomSurface = "Smooth"
p.Shape = "Ball"
p.CFrame = me.Character.Torso.CFrame * CFrame.new(Vector3.new(0, 0, -15))
local d = Instance.new("BodyGyro")
d.Parent = p
d.maxTorque = Vector3.new(math.huge, math.huge, math.huge)
d.cframe = CFrame.fromEulerAnglesXYZ(1.57, 0, 0)
local b = Instance.new("BodyVelocity")
b.Parent = p
b.maxForce = Vector3.new(math.huge, math.huge, math.huge)
b.velocity = mouse.Hit.lookVector * 100
game.ReplicatedStorage.Bubble1:clone().Parent = p
game:GetService("Debris"):AddItem(p,7) 
wait(0.1)
end

wait(5)
	mouse.Icon = "rbxasset://textures\\GunCursor.png"
	enabled = true

end

function onS(mouse) 
mouse.Button1Down:Connect(function() onButton1Down(mouse) end) 
end 
bin.Selected:Connect(onS)

Damage Script:

wait(0.01)
damage = 5
humanoidnames = {"Humanoid"}
function onTouched(hit)
if hit.Parent.Name ~= script.Parent.Name then
if hit.Parent.Parent.Name ~= script.Parent.Name then


for i = 1 , #humanoidnames do
local d = hit.Parent.Parent:findFirstChild(humanoidnames[i])
if d ~= nil then
d.Health = d.Health - damage
for i = 1 , 4 do
local p = Instance.new("Part")
p.Parent = game.Workspace
p.CanCollide = false
p.BrickColor = BrickColor.new("Bright blue")
p.Size = Vector3.new(1, 1, 1)
p.TopSurface = "Smooth"
p.BottomSurface = "Smooth"
p.CFrame = hit.CFrame
p.Velocity = Vector3.new(math.random(-50, 50), math.random(30, 50), math.random(-50, 50))
d = Instance.new("SpecialMesh")
d.Parent = p
d.MeshType = "Brick"
d.Scale = Vector3.new(0.2, 0.2, 0.2)
end

local torso = d.Parent:findFirstChild("Torso")
if torso ~= nil then
	torso.Velocity = torso.CFrame.lookVector * 2 + Vector3.new(0, 20, 0)
	torso.CFrame = torso.CFrame * CFrame.Angles(3.14, 0, 0)
end
script.Parent:Destroy()
end
end

end
end
end
script.Parent.Touched:Connect(onTouched)

1 comment

0

Are the scripts LocalScripts?