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

Change Camera Button Based On Save Data UnFunctional?

local Button = script.Parent
local camera = rooms:WaitForChild("Camera1")

Button.MouseButton1Click:connect(function()
p:WaitForDataReady()
    if p:LoadInstance("Toon3") == nil then
game.Workspace.CurrentCamera.CameraSubject = camera
game.Workspace.CurrentCamera.CameraType = "Scriptable"
game.Workspace.CurrentCamera.CoordinateFrame = CFrame.new(Camera1.Postion,CFrame.new(20,20,20))
game.ReplicatedStorage["CreateAToonGui"]:clone().Parent = game.Players.LocalPlayer.PlayerGui
end

What i tried to do is make the local script read of the player has any save instances called toon3 which is a custom morph inside the player. If there is none it should redirect the camera to a room and give them a gui. But its not working when i play the actual game as save instance does not work in studio. Thanks anyone that knows where i went wrong.

1 answer

✓ Accepted answer

You're using p as an unassigned variable... You need to assign it, I'm guessing it's player and a local script so:
Thanks to a little help from Wfvj014, the other issue: Again...


local Button = script.Parent

local camera = rooms:WaitForChild("Camera1")

local p = game.Players.LocalPlayer
 

Button.MouseButton1Click:connect(function()

p:WaitForDataReady()

    if p:LoadInstance("Toon3") == nil then

game.Workspace.CurrentCamera.CameraSubject = camera

game.Workspace.CurrentCamera.CameraType = "Scriptable"

game.Workspace.CurrentCamera.CoordinateFrame = CFrame.new(camera.Postion,CFrame.new(20,20,20)) -- Using Camera1 will most certainly throw the script off.

game.ReplicatedStorage["CreateAToonGui"]:Clone().Parent = game.Players.LocalPlayer.PlayerGui

end
end) -- Forgot an end) because anonymous function.

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