Client script remoteevent problem?
Thank you for reading this.
So, for my platformer game, i want to make a flagpole at the end something like super mario bros. I have this custom control script and a serverscript.
(Also the purpose of the controlOn variable is for the cutscene to happen without the player moving)
This is the error that pops up:
1 | 20 : 19 : 13.540 - Players.hasanchik.PlayerScripts.ControlScript: 46 : attempt to index boolean with 'Name' |
2 | 20 : 19 : 13.540 - Stack Begin |
3 | 20 : 19 : 13.541 - Script 'Players.hasanchik.PlayerScripts.ControlScript' , Line 46 |
4 | 20 : 19 : 13.541 - Stack End |
Server script:
01 | local ts = game:GetService( "TweenService" ) |
02 | local rs = game:GetService( "ReplicatedStorage" ) |
03 | local remote 1 = rs:WaitForChild( "PlayerControl" ) |
04 | local debris = game:GetService( "Debris" ) |
06 | local bottom = script.Parent.Flagpole.Bottom |
07 | local top = script.Parent.Flagpole.Top |
08 | local flag = script.Parent.Flagpole.Flag |
09 | local pole = script.Parent.Flagpole.Pole |
10 | function guiBegin(player) |
11 | local guiCoroutine = coroutine.create( function () |
12 | local gui = script.FadeOut:Clone() |
13 | local frame = gui:FindFirstChild( "FadeOutFrame" ) |
14 | gui.Parent = player.PlayerGui |
15 | local goal = { BackgroundTransparency = 0 } |
16 | local tweenInfo = TweenInfo.new( 1 , Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0 , false , 0 ) |
17 | local fadeIn = ts:Create(frame, tweenInfo, goal) |
20 | local goal = { BackgroundTransparency = 1 } |
21 | local tweenInfo = TweenInfo.new( 1 , Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0 , false , 0 ) |
22 | local fadeOut = ts:Create(frame, tweenInfo, goal) |
25 | debris:AddItem(gui, 0.1 ) |
27 | coroutine.resume(guiCoroutine) |
29 | pole.Touched:Connect( function (part) |
30 | local HRP = part.Parent:FindFirstChild( "HumanoidRootPart" ) |
31 | local player = game.Players:GetPlayerFromCharacter(part.Parent) |
32 | if HRP and player and not db then |
35 | local goal = { Position = Vector 3. new(HRP.Position.X,bottom.Position,HRP.Position.Z)+Vector 3. new( 0 , 3 , 0 ) } |
36 | local tweenInfo = TweenInfo.new( 1 , Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0 , false , 0 ) |
37 | local Glide = ts:Create(HRP, tweenInfo, goal) |
39 | bottom.LevelComplete:Play() |
43 | remote 1 :FireClient(player, false ) |
Client script:
01 | local player = game.Players.LocalPlayer |
02 | local RunService = game:GetService( "RunService" ) |
03 | local ContextActionService = game:GetService( "ContextActionService" ) |
04 | local rs = game:GetService( "ReplicatedStorage" ) |
05 | local remote 1 = rs:WaitForChild( "PlayerControl" ) |
09 | local leftValue, rightValue = 0 , 0 |
11 | local function onLeft(actionName, inputState) |
12 | if inputState = = Enum.UserInputState.Begin then |
14 | elseif inputState = = Enum.UserInputState.End then |
19 | local function onRight(actionName, inputState) |
20 | if inputState = = Enum.UserInputState.Begin then |
22 | elseif inputState = = Enum.UserInputState.End then |
27 | local function onJump(actionName, inputState) |
28 | if inputState = = Enum.UserInputState.Begin then |
30 | elseif inputState = = Enum.UserInputState.End then |
35 | local function onUpdate() |
36 | if player.Character and player.Character:FindFirstChild( "Humanoid" ) and controlOn then |
38 | player.Character.Humanoid.Jump = true |
40 | local moveDirection = rightValue - leftValue |
41 | player.Character.Humanoid:Move(Vector 3. new(moveDirection, 0 , 0 ), false ) |
45 | remote 1. OnClientEvent:Connect( function (player 2 , controlOn 2 ) |
46 | if player 2. Name = = player.Name then |
47 | controlOn = controlOn 2 |
51 | RunService:BindToRenderStep( "Control" , Enum.RenderPriority.Input.Value, onUpdate) |
53 | ContextActionService:BindAction( "Left" , onLeft, true , "a" , Enum.KeyCode.Left, Enum.KeyCode.DPadLeft) |
54 | ContextActionService:BindAction( "Right" , onRight, true , "d" , Enum.KeyCode.Right, Enum.KeyCode.DPadRight) |
55 | ContextActionService:BindAction( "Jump" , onJump, true , "w" , Enum.KeyCode.Space, Enum.KeyCode.Up, Enum.KeyCode.DPadUp, Enum.KeyCode.ButtonA) |
Can you help me? Thanks.