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:
20:19:13.540 - Players.hasanchik.PlayerScripts.ControlScript:46: attempt to index boolean with 'Name'
20:19:13.540 - Stack Begin
20:19:13.541 - Script 'Players.hasanchik.PlayerScripts.ControlScript', Line 46
20:19:13.541 - Stack End
Server script:
local ts = game:GetService("TweenService")
local rs = game:GetService("ReplicatedStorage")
local remote1 = rs:WaitForChild("PlayerControl")
local debris = game:GetService("Debris")
local db = false
local bottom = script.Parent.Flagpole.Bottom
local top = script.Parent.Flagpole.Top
local flag = script.Parent.Flagpole.Flag
local pole = script.Parent.Flagpole.Pole
function guiBegin(player)
local guiCoroutine = coroutine.create(function()
local gui = script.FadeOut:Clone()
local frame = gui:FindFirstChild("FadeOutFrame")
gui.Parent = player.PlayerGui
local goal = {BackgroundTransparency = 0}
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
local fadeIn = ts:Create(frame, tweenInfo, goal)
fadeIn:Play()
wait(2.1)
local goal = {BackgroundTransparency = 1}
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
local fadeOut = ts:Create(frame, tweenInfo, goal)
fadeOut:Play()
wait(1)
debris:AddItem(gui, 0.1)
end)
coroutine.resume(guiCoroutine)
end
pole.Touched:Connect(function(part)
local HRP = part.Parent:FindFirstChild("HumanoidRootPart")
local player = game.Players:GetPlayerFromCharacter(part.Parent)
if HRP and player and not db then
db = true
HRP.Anchored = true
local goal = {Position = Vector3.new(HRP.Position.X,bottom.Position,HRP.Position.Z)+Vector3.new(0,3,0)}
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0)
local Glide = ts:Create(HRP, tweenInfo, goal)
Glide:Play()
bottom.LevelComplete:Play()
wait(1)
HRP.Anchored = false
db = false
remote1:FireClient(player, false)
end
end)
Client script:
local player = game.Players.LocalPlayer
local RunService = game:GetService("RunService")
local ContextActionService = game:GetService("ContextActionService")
local rs = game:GetService("ReplicatedStorage")
local remote1 = rs:WaitForChild("PlayerControl")
local controlOn = true
local jumping = false
local leftValue, rightValue = 0, 0
local function onLeft(actionName, inputState)
if inputState == Enum.UserInputState.Begin then
leftValue = 1
elseif inputState == Enum.UserInputState.End then
leftValue = 0
end
end
local function onRight(actionName, inputState)
if inputState == Enum.UserInputState.Begin then
rightValue = 1
elseif inputState == Enum.UserInputState.End then
rightValue = 0
end
end
local function onJump(actionName, inputState)
if inputState == Enum.UserInputState.Begin then
jumping = true
elseif inputState == Enum.UserInputState.End then
jumping = false
end
end
local function onUpdate()
if player.Character and player.Character:FindFirstChild("Humanoid") and controlOn then
if jumping then
player.Character.Humanoid.Jump = true
end
local moveDirection = rightValue - leftValue
player.Character.Humanoid:Move(Vector3.new(moveDirection,0,0), false)
end
end
remote1.OnClientEvent:Connect(function(player2, controlOn2)
if player2.Name == player.Name then
controlOn = controlOn2
end
end)
RunService:BindToRenderStep("Control", Enum.RenderPriority.Input.Value, onUpdate)
ContextActionService:BindAction("Left", onLeft, true, "a", Enum.KeyCode.Left, Enum.KeyCode.DPadLeft)
ContextActionService:BindAction("Right", onRight, true, "d", Enum.KeyCode.Right, Enum.KeyCode.DPadRight)
ContextActionService:BindAction("Jump", onJump, true, "w", Enum.KeyCode.Space, Enum.KeyCode.Up, Enum.KeyCode.DPadUp, Enum.KeyCode.ButtonA)
Can you help me? Thanks.

1 comment
See the comment on my answer