Actually… it still kills people
But I set damage to 0… hm well, I’ll keep trying
Try adding
function onTouched(hit)
if not game.Players:GetCharacterFromPlayer(hit:FindFirstAncestorOfClass('Model')) then -- This just checks if there is a first ancestor of Hit that is a model, and that it doesn't belong to a player.
hit:BreakJoints()
wait(0.5)
pellet:Destroy()
end
end
ok, I’ll try it, just a second
Same problem… I do not know how to fix this
Thanks, though. I’ll keep trying
My mistake, it should be:
if not game.Players:GetPlayerFromCharacter(hit:FindFirstAncestorOfClass('Model')) then
hit:BreakJoints()
wait(0.5)
pellet:Destroy()
end
If it doesn’t work, try this:
Slingshot.rbxm (8.3 KB)
Still nothing… what does the file you attached do?
It’s just a model of a slingshot.
Anyone have any more ideas? Thanks
Could it be that the explosions created in the game have an effect on the character?
Actually, there are no explosions in my game. However, I fixed it temporarily by making the pellets made of brick, so they do not bounce back as much. And, it’s more satisfying.
Okay, so people don’t die anymore, but sometimes the pellet will delete the slingshot itself if the pellet is touching the slingshot. Any ideas?
Can you send all of your current code and a picture of what explorer looks like?
Okay, now I added a drop smash! With that, I don’t have slingshot issues, since you drop stuff from high up.
Here’s the code that is probably the problem:
local debris = game:service(“Debris”)
pellet = script.Parent
damage = 0
function onTouched(hit)
if not hit or not hit.Parent then return end
local humanoid = hit.Parent:FindFirstChildOfClass(“Humanoid”)
if humanoid then
else
hit:BreakJoints()
wait(.5)
pellet:Destroy()
end
end
script.Parent.Touched:connect(onTouched)
function tagHumanoid(humanoid)
– todo: make tag expire
local tag = pellet:FindFirstChild(“creator”)
if tag then
– kill all other tags
while(humanoid:FindFirstChild(“creator”)) do
humanoid:findFirstChild(“creator”).Parent = nil
end
local new_tag = tag:Clone()
new_tag.Parent = humanoid
debris:AddItem(new_tag, 1)
end
end
connection = pellet.Touched:Connect(onTouched)
r = game:service(“RunService”)
t, s = r.Stepped:Wait()
d = t + 2.0 - s
while t < d do
t = r.Stepped:Wait()
end
(Heads up - next time you post code, put it in a code block so it looks nicer!)
```
(paste code between 3 backticks,
the backticks have to be on their own line with nothing else
they are not apostrophes)
```
Let’s go back to the start.
function onTouched(hit)
hit:BreakJoints() -- break the hit part
wait(0.5)
pellet:Destroy() -- disappear after 0.5 seconds
end
The pellet is breaking everything, including players and the slingshot itself.
You say it should not destroy players.
A player is usually something that has a Humanoid in it.
So the obvious choice is pretty much what you had in your last post:
function onTouched(hit)
local humanoid = hit.Parent:FindFirstChildOfClass("Humanoid") -- look for a Humanoid in the Parent of the hit part
if humanoid then -- was there a Humanoid there?
-- do nothing if there was!
else
hit:BreakJoints() -- break the hit part
end
-- regardless of what was hit,
wait(0.5)
pellet:Destroy() -- disappear after 0.5 seconds
end
So why would this not work?
Can it knock Hats off your own player? Can it break cars and such, but not stuff directly in the workspace?
If so, then there’s probably a Humanoid object right there in the Workspace, making the pellet think it’s hitting a character.
Other than that, I have no clue.
Even then, 7z99’s solution should’ve worked just as well! You’re either doing something really wrong or are missing something really small.