Script works perfectly for me, but no one else

I recently finished scripting an npc in my game, he’s meant to take you to a different part of the map when talked to. Today I brought my friend on to show him the game since he was interested, but this script seems like it doesn’t even “turn on” for him. I also tried this with another friend, and it didn’t work for them either.

local Player = game.Players.LocalPlayer
local Character = Player.Character
local Shop = game.Workspace.MapItself:WaitForChild("CrenacDock")
local Craan = Shop:WaitForChild("Craan")
local TalkPart = Craan:WaitForChild("TalkPart")
local Humanoid = Craan.Humanoid
local AnimFolder = Craan.Animations
local Idle = Humanoid:LoadAnimation(AnimFolder.Idle)
local Camera = game.Workspace.Camera
local ButtonPressed = ""
Idle:Play()

local Options = script.Parent.Options
local NothingButton = Options.Nothing
local VisitIslandofCalamity = Options.VisitIslandofCalamity

NothingButton.MouseButton1Click:Connect(function() -- These functions don't even work when my friend clicks on these buttons.
	print("Nothing Clicked")
	ButtonPressed = "Nothing"
end)

VisitIslandofCalamity.MouseButton1Click:Connect(function() -- This one doesn't work as well.
	print("VisitIslandofCalamity Clicked")
	ButtonPressed = "VisitIslandofCalamity"
end)

TalkPart.ProximityPrompt.Triggered:Connect(function(player) -- Although this function does work.
	ButtonPressed = ""
	TalkPart.ProximityPrompt.Enabled = false
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CFrame = Craan.CameraPart.CFrame
	Character.Head.Anchored = true
	
	script.Parent.Enabled = true
	local done = false
	local function typewrite(label, text, waitingTime)
		for i = 1, #text do
			label.Text = string.sub(text, 1, i)
			wait(waitingTime)
		end
		done = true
	end
	
	done = false
	typewrite(script.Parent.TextBackground.TextLabel, "What do you want?", .06)
	repeat wait() until done == true
	
	script.Parent.Options.Visible = true
	
	repeat wait() until ButtonPressed ~= ""
	
   -- And I believe this is where it just stops, as the button functions above don't fire.

	if ButtonPressed == "VisitIslandofCalamity" then
		print("Recieved VisitIslandofCalamity")
		local Suits = game.ReplicatedStorage.Craan.RequestSuits:InvokeServer()
		print(Suits)
		local DarkSuit = false
		for i, v in pairs(Suits) do
			print(i, v)
			if v == "DarkSuit" then
				DarkSuit = true
			end
		end
		if DarkSuit == true then
			script.Parent.Options.Visible = false
			ButtonPressed = ""
			done = false
			typewrite(script.Parent.TextBackground.TextLabel, "Crenac, huh? Your choice, not mine.", .06)
			repeat wait() until done == true
			wait(1)
			----------------------- Teleport code goes here --------------------------------------
			local ScreenGui = player.PlayerGui.ScreenUI
			local TeleportUI = ScreenGui.CrenacTeleportUI
			TeleportUI.Visible = true
			TeleportUI:TweenPosition(UDim2.new(.5, 0,0.5, 0), Enum.EasingDirection.In, Enum.EasingStyle.Sine, .8)
			wait(2)
			Character.Humanoid.Sit = false
			ScreenGui.Corruption.Visible = true
			wait(.2)
			Character.HumanoidRootPart.CFrame = game.ReplicatedStorage.CrenacBoat.TeleportBrick.CFrame
			TeleportUI:TweenPosition(UDim2.new(0.5, 0,1.5, 0), Enum.EasingDirection.In, Enum.EasingStyle.Sine, .8)
			
			TalkPart.ProximityPrompt.Enabled = true
			Camera.CameraType = Enum.CameraType.Custom
			script.Parent.Enabled = false
			Character.Head.Anchored = false
		else
			script.Parent.Options.Visible = false
			ButtonPressed = ""
			done = false
			typewrite(script.Parent.TextBackground.TextLabel, "Kid, you don't even have the gear to go to the island, so don't bother.", .06)
			repeat wait() until done == true
			wait(1)
			TalkPart.ProximityPrompt.Enabled = true
			Camera.CameraType = Enum.CameraType.Custom
			script.Parent.Enabled = false
			Character.Head.Anchored = false
			game.ReplicatedStorage.ClientNotifEvent:FireServer("", "You need the Dark Suit to go to the Island of Calamity.")
			game.ReplicatedStorage.ClientSendChatMessage:FireServer("You need to obtain the Dark Suit to go to the Island of Calamity.")
		end
	elseif ButtonPressed == "Nothing" then
		print("Recieved Nothing")
		script.Parent.Options.Visible = false
		done = false
		typewrite(script.Parent.TextBackground.TextLabel, "Scat.", .06)
		repeat wait() until done == true
		wait(.5)
		TalkPart.ProximityPrompt.Enabled = true
		Camera.CameraType = Enum.CameraType.Custom
		script.Parent.Enabled = false
		Character.Head.Anchored = false
	end
end)

Thank you.

If you attach a video that would be great!

Yes. Here are videos of my problem.
This video is of it working for me:


And here’s a video of it not working for my friend:
robloxapp-20210723-2118433.wmv (2.2 MB)

Sorry for responding 40 minutes late

It’s probably not “turning on” for him because you don’t see anything while you’re traveling, just a loading screen, if you showed like a 5 second cutscene of the NPC rowing the boat. it may then “turn on” for him.

I don’t think just adding a cutscene would fix the problem. The options gui should also completely disappear after clicking one option, which shows the MouseButton1Click function doesn’t fire at all, so adding a cutscene would be useless because it wouldn’t even happen.

May you used localscrit instead of a normal script?

1 Like

I did use a local script, as I don’t think a normal server script would really work.

Are you sure the 2 button connections never fire? If you’re looking at the dev console, you can only see output from the server and your client, meaning you have to ask your friend to show you their output.

Yeah, after the first time it happened I added the prints, and told my friend to send a screenshot of the developer console. All it had was stuff unrelated to the script.

It’ll work fine for yourself as it’s a localscript, therefore it’s client-sided, hence, only you’re able to see what you’re doing - and the actions aren’t replicated to the servers for others to see.

You’d want to use RemoteEvents to do this, which communicate by localscripts to scripts. In your situation, use this for changing your HumanoidRootPart's CFrame, so everyone can see you teleporting, and other stuff which you want others to see. Here’s an example:

--localscript
local rep = game:GetService("ReplicatedStorage")
local remote = rep.RemoteEvent

remote:FireServer("change CFrame")

--script
local rep = game:GetService("ReplicatedStorage")
local remote = rep.RemoteEvent

remote.OnServerEvent:Connect(function(plr, msg)
    if msg == "change CFrame" then
        plr.Character.HumanoidRootPart.CFrame = rep.CrenacBoat.TeleportBrick.CFrame
    end
end)

Besides, the reason why the buttons might not work, is likely because these events are in a script, or aren’t really buttons.

I do actually realize now that I will have to teleport players via server script, although that’s not the problem. Sorry if I didn’t explain it well enough, so I’ll explain it again here. The problem I’m having is that the script only works for me, not my friend. My friend is able to go as far as having the options tab open, but not click the buttons. The problem also won’t just be solved by changing the players position via server, since my friend literally can’t even get to the part in the script that’s supposed to teleport you since he can’t click the buttons. Also, the script that was shown in the post is a localscript. For more context, please compare the two videos in the second reply, since they show how I am able to click on the options, and my friend isn’t.

Players have the Network Ownership | Roblox Creator Documentation of their own character so changing their root part cframe from the server is unnecessary as it will get replicated from the client too.
Now the main issue seems pretty odd, were they using a different device, perhaps a mobile?

That’s good, and yes they were using a different device. Although it’s not mobile, and not really meant for playing many games.

Could you link the game if it’s public?

The Island of Fareo | Discontinued on Roblox - Roblox Here’s the game, I’ll probably leave it public tonight for you guys to test it. all you have to do is click the brick that says “Click me to get the Dark Suit!”, then go talk to the npc named Craan and try to click the button that says “Go to Crenac” or the nothing button, just to see.