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

what would i put instead of touched i this script?

I'm trying to teleport between places and it is coded for when a, for example, part it's not clicked but your character touches it and I'm doing this on a screen GUI text button and i have a script inside of that heres the script

function parentPressed()
	local TeleportService = game:GetService("TeleportService")
     
    local placeID_1 = 4944349183
    local placeID_2 = 4896092768
     
    local function onPartTouch(otherPart)
    	local player = game.Players:GetPlayerFromCharacter(otherPart.Parent)
    	if player then
    		TeleportService:Teleport(placeID_1, player)
    	end
    end
    script.Parent.touched:Connect(onPartTouch)


    local TeleportService = game:GetService("TeleportService")
    local Players = game:GetService("Players")
     
    Players.PlayerAdded:Connect(function(player)
    	-- Is this player following anyone?
    	local followId = player.FollowUserId
    	-- If so, find out where they are
    	if followId and followId ~= 0 then
    		local success, errorMessage, placeId, jobId = pcall(function()
    			return TeleportService:GetPlayerPlaceInstanceAsync(followId)
    		end)
    		if success then
    			-- Teleport player
    			TeleportService:TeleportToPlaceInstance(placeId, jobId, player)
    		end
    	else
    		warn("Player " .. player.UserId .. " is not following another player!")
    	end
    end)




end
script.Parent.MouseButton1Down:connect(parentPressed)

1 comment

0

well if you want to make a button clickable on gui you use (1)local button = script.Parent (2)button.MouseButton1Click:Connect(function() script goes inside end)

1 answer

If you're asking alternatives for Touched, I recommend looking into Reigon3.

If you're asking a solution to the code, understand that all of this executes and can only execute when it is clicked.

Also, you mention script.Parent for both Touched and Clicked. If you have this script within a brick, you will need a click detector. I recommend looking into Click Detectors for information on that.

1 comment

0

thanks but i know about click detectors and ive used remote events i will try that but im not entirely sur about it

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