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

This function isn't working properly, why?

Asked by 10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

So, this I tested this in a local script, and a server script (default script), and none of them are working. This script was originally designed to work to the extent where when a player clicks the gui button, it teleports them, makes the gui non-visible, and locks the players screen in first person.

However, it isn't working. Help?

local Button = script.Parent
Frame = script.Parent.Parent.gggg


function onClick() 
game.Players.LocalPlayer.Character.Torso.CFrame = CFrame.new(-0,1,43)
wait()
    game.Players.LocalPlayer.Character.Torso.Anchored=true

    wait()

Frame.Visible = false

end 

Button.MouseButton1Click:connect(onClick)

1
You're using LocalPlayer, so you must use a LocalScript. BlueTaslem 18071 — 10y
0
I'm using a LocalScript. SmokeyIsSmoking 0 — 10y
0
Tested, works as it should. Trewier 146 — 10y
0
Is your script in a gui? SmokeyIsSmoking 0 — 10y
0
you can see what I did here: http://www.roblox.com/Tis-Working-place?id=190115560 Trewier 146 — 10y

2 answers

Log in to vote
0
Answered by
Trewier 146
10 years ago

Here is your final script:

local Button = script.Parent
Frame = script.Parent.Parent


function onClick() 
game.Players.LocalPlayer.Character.Torso.CFrame = CFrame.new(-0,1,43)
wait()
game.Players.LocalPlayer.Character.Torso.Anchored=true
wait()
game.Players.LocalPlayer.CameraMode = "LockFirstPerson"
Frame.Visible = false
end 

Button.MouseButton1Click:connect(onClick)

0
Thanks, helped a lot. SmokeyIsSmoking 0 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

Awesome, thanks guys I got it to function properly! Now I'm just experiencing one more tiny problem. First person isn't locking when the button is clicked.

local Button = script.Parent
Frame = script.Parent.Parent


function onClick() 
game.Players.LocalPlayer.Character.Torso.CFrame = CFrame.new(-0,1,43)
wait()
    game.Players.LocalPlayer.Character.Torso.Anchored=true

    wait()

Frame.Visible = false
script.Parent.Parent.CameraMode="LockFirstPerson"
end 

Button.MouseButton1Click:connect(onClick)

I have script.Parent.Parent.CameraMode="LockFirstPerson" which should be correct, this script is local and it's in StarterGui.

0
Here was my previous problem in which it wasn't working: 'Frame = script.Parent.Parent.gggg' .gggg wasn't necessary SmokeyIsSmoking 0 — 10y
0
I've done the way I did previously before and it worked fine, I just haven't put it into a scrypt like this. SmokeyIsSmoking 0 — 10y
0
Figured it out: game.Players.LocalPlayer.CameraMode = "LockFirstPerson" Trewier 146 — 10y
0
Isn't it sopoused to be game.Players.LocalPlayer.CameraMode.LockFirstPerson = true? Operation_Meme 890 — 10y
View all comments (3 more)
0
Both should work, however I haven't tested it. Trewier 146 — 10y
0
You could try and use an enumeration: game.Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson Redbullusa 1580 — 10y
0
You could also try to adjust the property within the "StarterPlayer" object in the player. Redbullusa 1580 — 10y

Answer this question