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

How do i make it where anyone can use a cash to collect and not limmited to the owner?

function onTouched(part)
	local h = part.Parent:findFirstChild("Humanoid")
	if (h~=nil) then
		local player = script.Parent.Parent.Parent.Workspace
		if h.Parent.Name == Player then --If the one who pressed the button is the owner then
			local thisplr = game.Players:findFirstChild(h.Parent.Name)
			if (thisplr~=nil) then
				local stats = thisplr:findFirstChild("leaderstats")
				if (stats~=nil) then
					local score = stats:findFirstChild("Money")
					if (score~=nil) then
						score.Value = score.Value + script.Parent.Parent.Money.Value
						script.Parent.Parent.Money.Value = 0
					end
				end
			end
		end
	end
end

script.Parent.Touched:connect(onTouched)

OK, this may seem complex, but im trying to make a system, where you take a brick or part, drop it inside of an "cash to collect", and get points. My problem is..

TO get points, i dont want you to be owner. I want it to be anyone. If i could get some help, that would be awesome .IM not asking for a script. I just need help editing it -Beginner Scripter

1 comment

0

well is this a ServerScript or a LocalScript?

1 answer

I'm not 100% sure what you want, but from what I understand this is what I came up with. Change Line 5 to:

if game.Players[h.Parent.Name] then

If you need anymore help please don't hesitate to contact me!

5 comments

0

I corrected line 5, but I still got the error "workspace is not a valid member of Workspace PlayerName, but I still got an error that said, "PlayerName is not a valid member of Workspace"

0

What line is the error on?

0

Line 4

0

Ok, can you add my discord so we can resolve this problem easier? Trev#0924

0

Sure

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