I want to print “hi” when a player is touching the part with an equipped tool and activated
the activated part doesn’t work and i don’t know why thanks for those who help i appreciate it a lot
Sometimes when I try to use the .Activated event on Roblox Studio it doesn’t work, but should work on the roblox client. Have you tried checking on an actual game?
You are making all your connections to the functions in the wrong way for instance the server script you have will repeatedly make connections to all the parts over and over if that ever does fire the clients its going to be many many times at once
your activated should be connected to directly in the base tool script same with equipped
Try this directly in your tool script you will see what i mean
local Tool = script.Parent
Tool.Activated:Connect(function()
print('Hi i have been Activated')
end)
Tool.Equipped:Connect(function()
print('Hi i have been Equipped')
end)
Tool.Unequipped:Connect(function()
print('Hi i have been Unequipped')
end)
Also you should remove the while loop you have in your server script or atleast put the for loop thats making connections outside of it
“Also you should remove the while loop you have in your server script or at least put the for loop thats making connections outside of it”
i want the game check when player is standing on that specific part that part’s parent is the folder
i mean whats inside the folder should be acceptable for touch and do the event
This is really all you need in the tool script it will set an attribute when the tool is being activated and held down when they let off mouse it will remove the activated attribute
local Tool = script.Parent
Tool.Activated:Connect(function() -- this will add the activated attribute so you can check on server if tool is activated
print('Hi i have been Activated')
Tool:SetAttribute('Activated', true)
end)
Tool.Deactivated:Connect(function() -- this will remove the activated attribute
print('Hi i have been Deactivated')
Tool:SetAttribute('Activated', nil)
end)
now on the server in the touched function get the Tool from the character and do
if Tool:GetAttribute('Activated') then
--- do something here their tool is active
end
do you see the printouts from that when you click while tool is equip?
also your remote event is setup wrong you don’t do the equip connection in there like that its is done in the base script for the tool same as i posted above
no need for it in the event…
then if you leave the activated it might work if all else is good on server side
this part here would go in the server script in the tool the part on that post at bottom is where you check on the server in the touched event then you fire the clients if that attribute is on that tool Server script in tool
this is probably what you need on your server side like i explaining in the above post.
for i, v, in ipairs(mopablefolder:GetChildren()) do -- you only loop through these once no need for while loop like i said above
v.Touched:Connect(function(hit) -- make a connection to touched function for this part
if hit.Parent:FindFirstChild('Humanoid') then -- see if humanoid/character
local Tool = hit.Parent:FindFirstChild('TOOL NAME GOES HERE') -- make sure to change to your tools name -- this gets the tool if they player has it equipped..
if Tool then -- the tool is in the character
if Tool:GetAttribute('Activated') then -- if this attribute is there then the tool is currently active
Event:FireAllClients(v) -- so fire all clients
end
end
end
end)
end
now on your client side you will need a local script somewhere that has the event setup in it so when the server fires it will run the code you want