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

Leaderstats pay to enter portal help?

I've been trying to make a portal you can go through only by paying ONCE. I've been at this for an hour but no luck. Hoping someone here can answer. Here is my code:

function onTouch(part)
	if part.Parent.Humanoid ~=nil then
		part.Parent:MoveTo(workspace.Spawns["Area 3"]["Area 3 Spawn"].Position)
		script.Parent.Parent.SpawnTo3.Script.Disabled = true
		wait(2)
		script.Parent.Parent.SpawnTo3.Script.Disabled = false
	end
end

script.Parent.Touched:connect(onTouch)

1 answer

✓ Accepted answer

uh maybe dis work hehe

-- first make data for portal
script.Parent.Touched:Connect(function(hit)
	local character = hit.Parent
	local player = game.Players:GetPlayerFromCharacter(character)
	if player ~= nil then
		if player.Data.Portal1 == true then -- see if they have and ends script if they do so they dont pay again
			character:MoveTo(location) -- tp them
			return
		end
		if player.Data.currency >= amountPay then
			player.Data.currency -= ammountPay
			player.Data.Portal1 = true
			character:MoveTo(position)
		end
-- finish ends and stuff
		
		

3 comments

0

Data is not a valid member of Player "Players.agentgamer100" sorry im a beginneer what do i do about this?

0

oh. you need to make the datastore first. also, it wouldnt be player.Data. (just using that as an example) I use profileservice so i would do something like require(PATH_TO_MODULE)[player].Data.Portal1

0

there are other ways to make data. just edit the one part to match how your data is set up. I dont think im allowed to just give full scripts here bc it usually gets deleted for some reason.

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