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

Whenever I go in-game to test my scripts, they don't work. Help?

Asked by 10 years ago

This script works, but is there anything preventing it from working in-game?

01Player = game.Players.LocalPlayer
02Character = Player.Character
03Torso = Character.Torso
04Mouse = Player:GetMouse()
05RS = Character.Torso["Right Shoulder"]
06LS = Character.Torso["Left Shoulder"]
07hold = false
08f = script.Parent
09 
10Mouse.KeyDown:connect(function(key)
11    key = key:lower()
12    if key == "v" then
13        RS.C0 = RS.C0 * CFrame.Angles(0,.5,1)
14        LS.C0 = LS.C0 * CFrame.Angles(0,-.5,-1)
15 
View all 53 lines...
0
any errors? BringUpon 25 — 10y

1 answer

Log in to vote
2
Answered by 10 years ago

What cause this?

Why aren't my scripts running in the server? Easy Answer, Because Some scripts will run before the player is even in the game, casting an error.

How do I stop this?

How do I stop this madness? Well you can use the WaitForChild or repeat wait() until childName.

What is WaitForChild?

WaitForChild, yields the current thread, if a child with the given title, then returns the child, and Continues on. What if the Child didn't exist, then your code(code below WaitForChild) will not run at all.

01Player = game.Players.LocalPlayer
02 
03repeat wait() until Player.Character
04 
05Character = Player.Character
06Torso = Character:WaitForChild("Torso")
07Mouse = Player:GetMouse()
08RS = Torso["Right Shoulder"]
09LS = Torso["Left Shoulder"]
10hold = false
11f = script.Parent
12 
13Mouse.KeyDown:connect(function(key)
14    key = key:lower()
15    if key == "v" then
View all 56 lines...
0
Thia is an exact copy of a previously posted answer. No effort = no upvote. unmiss 337 — 10y
0
Actually I got the WaitForChild from "TheContinentofEurope", If I had no effort you should post an answer. BringUpon 25 — 10y
0
Exactly, you copied it. unmiss 337 — 10y
0
doesn't work. tyler46783 0 — 10y
Ad

Answer this question