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

2D-3D Changing script not working?

Asked by 9 years ago

I'm trying to make a script run off a while true do loop, so that after a given amount of time, the script will go from 2d-3d and then 3d-2d I get this error: 16:48:50.769 - Workspace.Script:98: ')' expected (to close '(' at line 54) near 'while'

Here's the main script


while true do function onPlayerRespawned(newPlayer) while newPlayer.Character == nil do wait(.1) end local h = newPlayer.Character.Humanoid local torso = h.Parent.Torso local hatmass = 0 for i = 1, #h.Parent:getChildren() do if h.Parent:getChildren()[i].className == "Hat" then hatmass = h.Parent:getChildren()[i].Handle:getMass() print(hatmass) end end local bp = Instance.new("BodyPosition") bp.Name = "2D-Movement" wait(.1) bp.position = torso.Position bp.P = 1000000 bp.D = 1000000 bp.maxForce = Vector3.new(10, 10, 10) bp.Parent = torso local bf = Instance.new("BodyForce") bf.force = Vector3.new(0, 4*(14+hatmass), 0) bf.Parent = torso local cam = Instance.new("Part") cam.Name = "" ..torso.Parent.Name.. "Camera" cam.CFrame = CFrame.new(torso.Position + Vector3.new(0, 0, 3), torso.Position) cam.Transparency = 1 cam.CanCollide = false cam.Parent = game.Workspace local bp = Instance.new("BodyPosition") bp.position = cam.Position bp.maxForce = Vector3.new(1000000, 1000000, 1000000) bp.Parent = cam local bg = Instance.new("BodyGyro") bg.maxTorque = Vector3.new(0, 0, 0) bg.Parent = cam local scr = script.LocalScript:clone() scr.Disabled = false scr.Parent = torso.Parent end function onPlayerAdded(newPlayer) newPlayer.Changed:connect(function(property) if property == "Character" then onPlayerRespawned(newPlayer) end wait(10) local larm = script.Parent:FindFirstChild("Left Arm") local rarm = script.Parent:FindFirstChild("Right Arm") function findNearestTorso(pos) local list = game.Workspace:children() local torso = nil local dist = 1000 local temp = nil local human = nil local temp2 = nil for x = 1, #list do temp2 = list[x] if (temp2.className == "Model") and (temp2 ~= script.Parent) then temp = temp2:findFirstChild("Torso") human = temp2:findFirstChild("Humanoid") if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then if (temp.Position - pos).magnitude < dist then torso = temp dist = (temp.Position - pos).magnitude end end end end return torso end function Hit(hit) local human = hit.Parent:FindFirstChild("Humanoid") if human ~= nil then human.Health = human.Health -8 end end larm.Touched:connect(Hit) rarm.Touched:connect(Hit) end

Local script inside:

local player = game.Players.LocalPlayer
local camera = game.Workspace:findFirstChild("" ..player.Name.. "Camera")
local cam = game.Workspace.CurrentCamera
cam.CameraSubject = camera
cam.CameraType = "Attach"

while player ~= nil do
if player.Character ~= nil then
if player.Character.Humanoid.Health == 0 then break end
camera.BodyPosition.position = player.Character.Torso.Position + Vector3.new(0, 0, 3)
camera.BodyGyro.cframe = CFrame.new(camera.Position, player.Character.Torso.Position)
wait(0.05)
else break end
end
wait(3)
camera:remove()

THANKS!

0
All you need to do is ad a ')' after the 'end' on line 96. It just needs you to close the parentheses from the start of the function. dyler3 1510 — 9y
0
Please put the full script. HungryJaffer 1246 — 9y
0
this is the full script ghosteffectz 115 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

Add "end)" to line 58

the shorthandFunction was never closed

Ad

Answer this question