Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Player Added script not working? (UPDATED SCRIPT)

Asked by
TrollD3 105
8 years ago

So Mad studio has an intro where something falls and destroys the M. I made my own version of this and I wanted to script it so that for every person that joins the game would see the intro (therefore changing the cam. ) and before it changes the camera to a different location (menu location) . UPDATED: ITS A REGULAR SCRIPT INSIDE THE WORKSPACE

game.ReplicatedFirst:RemoveDefaultLoadingScreen() 
local FB = game.ReplicatedStorage.firstblack
local FG = game.ReplicatedStorage.firstgold
local SB = game.ReplicatedStorage.secondblack
local SG = game.ReplicatedStorage.secondgold
local TB = game.ReplicatedStorage.thirdblack
local TG = game.ReplicatedStorage.thirdgold
local Sound = game.ReplicatedStorage.Sound
local Sound2 = game.ReplicatedStorage.Sound2
local intro = game.ReplicatedStorage.introbuilding
local cam = game.Workspace.CurrentCamera

cam.CameraType = "Scriptable"


game.Players.PlayerAdded:connect(function(player)
    Sound:Clone()
intro:Clone()
Sound2:Clone()
FB:Clone()
FG:Clone()
SB:Clone()
SG:Clone()
TG:Clone()
TB:Clone()

    print("Testing Intro with Player:" .. player.Name)
    wait(2)
intro.Parent = cam
FB.Parent = cam
FG.Parent = cam
SB.Parent = cam
SG.Parent = cam
TG.Parent = cam
TB.Parent = cam

cam.CoordinateFrame = CFrame.new(-79.86, 15.574, -68.35)*CFrame.Angles(0,109.95,0) ----Intro Cam LOCATION  
wait(2)
 -- The sounds cannot be in workspace becuase everyone would hear it ....
-- so do I clone it to the Local player? 
Sound:Play()
FB.script.Disabled = false -- to make the animated bricks to start working
FG.script.Disabled = false
SB.script.Disabled = false
SG.script.Disabled = false
TG.script.Disabled = false
TB.script.Disabled = false

if SG.Transparency ==0 then 

        repeat
    wait(.10)
    Sound.Volume = Sound.Volume-.15
until
Sound.Volume == 0
        --- there isnt an end so Idk if this will break the script cause Sound2 cant play yet...
---Possible error?
cam.CoordinateFrame = CFrame.new(-164, 13.46, -58.15)*CFrame.Angles(0,109.95,0)--NEW CAM LOCATION
Sound2:Play()
Sound2.Looped = true -- the end.




end
    end)




0
Try making a script that clones that script into the player's backpack when a player joins? E.G: function added() end game.Players.PlayerAdded:connect(added) TheDeadlyPanther 2460 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

I see major issues. You need to consider replication, and context

If this is a LocalScript, then you're in trouble because all of

local FB = game.ReplicatedFirst.firstblack:Clone()
local FG = game.ReplicatedFirst.firstgold:Clone()
local SB = game.ReplicatedFirst.secondblack:Clone()
local SG = game.ReplicatedFirst.secondgold:Clone()
local TB = game.ReplicatedFirst.thirdblack:Clone()
local TG = game.ReplicatedFirst:Clone()
local Sound = game.ReplicatedFirst.Sound:Clone()
local Sound2 = game.ReplicatedFirst.Sound2:Clone()
local intro = game.ReplicatedFirst.introbuilding:Clone()

might not have loaded yet. You're also about to reach the problem that Players.PlayerAdded can't be used properly in a LocalScript.

If it's a server script, good luck doing any of this

local cam = game.Workspace.CurrentCamera
cam.CameraType = "Scriptable"
game.ReplicatedFirst:RemoveDefaultLoadingScreen()

because all of that stuff is LocalScript only.

0
What if I put all that in the Lightning? As for the Player Added..... it should still work. and I quote this from wiki "Up until recently, this event didn't work on the client (in localscripts), but this has been changed" TrollD3 105 — 8y
0
It won't work for what you want I mean to say. Context. User#6546 35 — 8y
0
What do you mean by "replication and context"? TrollD3 105 — 8y
0
Replication is how the left hand knows what the right hand is doing, and context is which hand. Just replace the hands with the server and client respectively, of course. User#6546 35 — 8y
Ad

Answer this question