Dash system error

Hey, I’m having some issues with this dash script.
Basically whats erroring is the render function, for some reason.
if anyone knows why, please let me know.

--// SERVICES

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GuiService = game:GetService("GuiService")
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

--// VARIABLES

local DashFolder = ReplicatedStorage:WaitForChild("Dash")
local DashRemote = DashFolder:WaitForChild("Dash")

local Player = Players.LocalPlayer

--// FUNCTIONS

task.wait(5)

-->> Get Device

function GetDevice()

	if GuiService:IsTenFootInterface() then
		return "Console"
	elseif UserInputService.TouchEnabled and not UserInputService.MouseEnabled then
		return "Mobile"
	else
		return "Desktop"
	end

end

-->> Activated

function Activated()

	DashRemote:Fire()

end

script.Parent.Activated:Connect(Activated)

-->> Render

function Render()

	local Device = GetDevice()
	if Device == "Desktop" then
		if Player then
			if tonumber(Player:GetAttribute("Dash")) ~= nil then
				if Player:GetAttribute("Dash") <= 0 then
					script.Parent.Text = "Dash - " .. tostring(Player:GetAttribute("DashKey"))
				else
					script.Parent.Text = "Dash - " .. tostring(Player:GetAttribute("Dash")) .. "s"
				end
			end
		end
	end

end

RunService.RenderStepped:Connect(Render)

Thank you.

Still haven’t found a solution.
anyone?

It’s the “if Player then” line.
It’s meant to be “if player ~= nil then”
This is because in an if statement you can only exclude the equals mark if the variable your using is true or false (A boolean).
The player is either the player itself (game.Players.PlayerName) or nil
So if you don’t want that part of the script to run when the player doesn’t exist you just have to make sure the player isn’t nil

1 Like

Still the same error. Do u have any other ideas?

oh, Must have been the wrong line. Can you make it more clear where line 51 is since it’s not clear on your post

		if tonumber(Player:GetAttribute("Dash")) ~= nil then

It is in the “If” Statement though.

I managed to get the same kind of error when the attribute for dash in the player didn’t exist so I don’t think it’s the script
Dash Attribute Not Working (Helping some guy) 1
Same error (helping some guy)

What can I do to fix it then…?

Do something like below, and it should fix your problem.

if Player:GetAttribute("Dash") ~= nil then
    if tonumber(Player:GetAttribute("Dash")) ~= nil then
        -- rest of code

https://developer.roblox.com/en-us/api-reference/function/Instance/SetAttribute
Just use that and set dash to a number value or something like that at the start of that script.

Something like this
Player:SetAttribute(“Dash”, 2.5)