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

How can i make sure this script fires an event and an intro starts to play?

Greetings, i am making a game similar to cube cavern, "Blockie Cavern". I can't make the intro play due to the fact it doesn't error and/or doesn't work. If you can help, submit an answer below. Ill be sure to accept and give an upvote for it. I didn't use scriptservice because it is in the scriptservice.

( for some non user data and user data )

--The Server Script (used to add a folder for a players data and intro)
local rs = game:GetService("ReplicatedStorage")
local remotes = rs.Objects.RemoteEvents
local remotedused = remotes.AddGui

game.Players.PlayerAdded:Connect(function(client)
	---
	local plrvalue = Instance.new("Folder",game:GetService("ReplicatedStorage").Players)
	---
	plrvalue.Name = client.Name
	---
	local rs = game:GetService("ReplicatedStorage")
	---
	rs.Objects.Startup.Audio:Clone().Parent = game.Players[client.Name].PlayerGui
	---
	local plrgui = game.Players[client.Name].PlayerGui
	remotedused:FireClient(client,"GuiAdd")
	end)

game.Players.PlayerRemoving:Connect(function(plr)
	game:GetService("ReplicatedStorage").Players[plr.Name]:Destroy()
	print("Thank you for playing, come back soon!")
end) 
--Intro Script
local rs = game:GetService("ReplicatedStorage")
local remotes = rs.Objects.RemoteEvents
local remotedused = remotes.AddGui

script.Parent.AddGui.OnClientEvent:Connect(function(guiadd)
	if guiadd == "GuiAdd" then
		script.Parent.Intro:Clone().Parent = game.Players.LocalPlayer.PlayerGui
	end
end)


--[[ Ignore this, it's just for stuff i need to use for later.
	plrgui:WaitForChild("Audio")
	---
	plrgui.Audio.title:Play()
	wait(2)
	plrgui:FindFirstChild("Intro")
	wait(.5)
	plrgui.Intro.B1.Visible = true
	wait(2)
	plrgui.Intro.B2.Visible = true
	wait(1.5)
	plrgui.Intro.ImageLabel.Visible = true
	plrgui.Intro.TextButton.Visible = true
	wait(110)
	plrgui.Intro:Destroy()
--]]

1 comment

0

Your code will have two objects named the same inside of Players. Just name the folder 'Data' and parent to the folder.

1 answer

✓ Accepted answer

There is no reason for you make a Folder named as the player that is joining. If you want to store InstanceValues into the Folder you could just place the Folder into the player instance instead.

Cloning a ScreenGui to the PlayerGui could also be done in the PlayerAdded event. Intros usually start when a player joins too!

You also have a bunch of disorganized variables. Highly recommend fixing how your hierarchy looks in the Explorer.

--server script in serverscriptservice

--Define services at the top and USE them
local RS = game:GetService("ReplicatedStorage")

local Objects = RS.Objects
local Remotes = Objects.RemoteEvents
local Startup = Objects.Startup

local playerIntroEvent = Remotes.AddGui --Rename this 

game.Players.PlayerAdded:Connect(function(player)
	--Make a Folder and name it. "xPolarium_Data".
	local plrValue = Instance.new("Folder")
	plrValue.Name = player.Name.."_Data"
	plrValue.Parent = player

	--This part should probably be done in the client too
	--local newAudio = Startup.Audio:Clone()
	--newAudio.Parent = player.Character

	local newIntro = RS.IntroGui --If a ScreenGui called this is in RepStorage
	newIntro.Parent = player.PlayerGui

	playerIntoEvent:FireClient(player)
end)

Then you would set up your local script to listen for the event. Sometimes scripts can run before things load so make sure you properly :WaitForChild().

--local script in the screengui intro I had called "IntroGui".

local RS = game:GetService("ReplicatedStorage")

local playerIntroEvent = Remotes.AddGui

playerIntroEvent.OnClientEvent:Connect(function()
	--Here you do what ever you want the ScreenGui to show.
end)

The rest is up to you since you left the GUI editing out. If there's anything else I missed let me know.

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