I have a script that makes an orange (Like the fruit) weapon and I want to keep it a localscript. But I am having issues with doing damage. I want to have it so it does damage to anybody that touches it except the localplayer. But it does no damage at all. Could someone help me with this? And sorry if this is a really dumb question I'm a scripting noob.
Orange = Instance.new("Tool",game.Players.LocalPlayer.Backpack)
OrangeModel = Instance.new("Part",Orange)
OrangeModel.Shape = "Ball"
local player = "LocalPlayer"
playername = game.Players[player].Name
lpchar = game.Workspace[playername]
--Top
TopDecal = Instance.new("Decal",OrangeModel)
TopDecal.Texture = "http://www.roblox.com/asset/?id=4701252"
TopDecal.Face = "Top"
--Back
TopDecal = Instance.new("Decal",OrangeModel)
TopDecal.Texture = "http://www.roblox.com/asset/?id=4701252"
TopDecal.Face = "Back"
--Bottom
TopDecal = Instance.new("Decal",OrangeModel)
TopDecal.Texture = "http://www.roblox.com/asset/?id=4701252"
TopDecal.Face = "Bottom"
--Left
TopDecal = Instance.new("Decal",OrangeModel)
TopDecal.Texture = "http://www.roblox.com/asset/?id=4701252"
TopDecal.Face = "Left"
--Front
TopDecal = Instance.new("Decal",OrangeModel)
TopDecal.Texture = "http://www.roblox.com/asset/?id=4701252"
TopDecal.Face = "Front"
--Right
TopDecal = Instance.new("Decal",OrangeModel)
TopDecal.Texture = "http://www.roblox.com/asset/?id=4701252"
TopDecal.Face = "Right"
--Other
Orange.Name = "Orange"
OrangeModel.Name = "Handle"
--Size
Vector = Vector3.new(1,1,1)
OrangeModel.Size = Vector
--Damage Where it won't work
OrangeModel.Touched:connect(function(p)
if not p.Parent.Name == lpname then
p.Parent.Humanoid.Health = 0
end
end)
local tool = game.Players.LocalPlayer.Backpack.Orange
local animation = Instance.new("Animation")
local player = "LocalPlayer"
local function onActivate()
animation.AnimationId = "http://www.roblox.com/Asset?ID=28090109"
local animTrack = game.Players[player].Character.Humanoid:LoadAnimation(animation)
animTrack:Play()
end
tool.Activated:connect(onActivate)

1 comment
Im not an expert but I do believe the
if notpart is the problem. Generally the scripts where I usedif notdid not function very well or at all. So trying taking theIf notout and do try something else