Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

An equipped and activated script not working?

So, I really like the games Critical Strike and Project Submus Accudo and am trying to make a class but with a simpler idea. I was hoping that my script would work, but I have never done this type of scripting before so i couldn't figure out what was going wrong. (FYI I had a script in a part and that part was in a tool)

here is my code:

local tool = script.Parent.Parent
local ball = script.Parent
local move = ball.BodyForce

tool.Equipped:Connect(function(plr)
	local char = plr.Parent
	if char then
		print("part 1 done")
		tool.Activated:Connect(function(plr)
			print("part 2 done")
		end)
	end

1 answer

You cant get player through the equipped function, do this instead

local tool = script.Parent.Parent
local ball = script.Parent
local player
local char
local move = ball.BodyForce

tool.Equipped:Connect(function()
	char = tool.Parent
	player = game.Players:GetPlayerFromCharacter(char)
	if char then
		print("part 1 done")
		tool.Activated:Connect(function()
			print("part 2 done")
		end)
	end
end)

4 comments

0

my question is why is it not printing what I told it to print?

0

because if you try to get "plr" from the function it'll return nil and character isnt the parent of player

0

but i took your script put it in my game, but it still has the problem of not printing "part 1 done" or "part 2 done"

0

The issue is that you're using a LocalScript.

This discussion is preserved as it was. New answers, comments, and votes are closed.