Passive tool ability

so i want a tool to giv player passive effects when in players BACKPACK i scripted it, but for some reason it doesnt works, can someone give me an example of it?

maybe slow down player when he has the tool in backpack for example

3 Likes

If you mean when the tool is in the backpack object, you can do it like this:

local tool =  --insert tool location here

tool:GetPropertyChangedSignal("Parent"):Connect(function() --detects when tool's parent changes
if tool.Parent:IsA("Backpack") then --checks if tool is in player's backpack
--do something
end
end) 
1 Like

but it should do it to the player who has it in the backpack, i used parent too but for some reason it didnt do anything to the player, just for testing its ability was to set players health 0

Is it a server script and tool is assigned properly? It works for me, I put some prints as well and it works fine

Variation of that …
Testing.rbxl (60.6 KB)

1 Like

it kills parent.parent.parent… etc. but while it is in the backpack how can it fint the character, ima try that out thanks for your help

also thanks for your version too, i might use that one

how can i cancel the effect, or like apply another effect when player drops the item and gets rid of it, so it is no longer in backpack

like, player took it and now walk speed is 10, but when he drops it i wanna set walk speed to 16, how can i do this?

or how can i do it so it damages player over time, i tried


if tool.Parent:IsA("Backpack") then
	while tool.Parent.Name == "Backpack" do
	script.Parent.Parent.Parent.Character.Humanoid.Health -= 2
    end
end

tool:GetPropertyChangedSignal("Parent"):Connect(function()
	if tool.Parent:IsA("Backpack") then
		while tool.Parent.Name == "Backpack" do
			script.Parent.Parent.Parent.Character.Humanoid.Health -= 2
		end
	end
end)

and

local tool = script.Parent

if tool.Parent:IsA("Backpack") then
	while tool.Parent:IsA("Backpack") do
	script.Parent.Parent.Parent.Character.Humanoid.Health -= 2
    end
end

tool:GetPropertyChangedSignal("Parent"):Connect(function()
	if tool.Parent:IsA("Backpack") then
		while tool.Parent:IsA("Backpack")" do
			script.Parent.Parent.Parent.Character.Humanoid.Health -= 2
		end
	end
end)

you can use almost the same thing for this

local tool =  --insert tool location here

tool:GetPropertyChangedSignal("Parent"):Connect(function() --detects when tool's parent changes
if tool.Parent:IsA("Backpack") then --checks if tool is in player's backpack
--do something if backpack
elseif tool.Parent:IsA("Workspace") then
-- player has dropped item because it is in workspace, not character
end
end) 

it might not work if you want to get the original tool owner

Add a wait([seconds]) in the while loop, if not it will overload and crash studio
Other than that, the second one works better if there is something else named backpack in the player object

i added wait(0.5) and it still crashed

also thanks for all your help

[minimum character limit lol, i cant reply]

1 Like

add the wait in the while loop

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.