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

Displaying trail behind players that own gamepass, disable on click?

Asked by 4 years ago

I'm still learning how this work and trying my best. I can't do this by myself so I followed some tutorials and did some basic editing myself.

The first script is a script that I have inside a textbutton/gui. Some players that own the gamepass simply don't want to have the trail behind them. "SpeedDemonTrail" is the trail in serverstorage and I tried to make it so when the player clicks the button, it disables the trail but it says "SpeedDemonTrail is not a member of server storage"

local h = game.ServerStorage.SpeedDemonTrail
local Debounce = false

script.Parent.MouseButton1Click:Connect(function()
    if Debounce == false then
        h.Enabled = false
        script.Parent.Text = ("DemonTrail - OFF") 
        Debounce = true
    else
        h.Enabled = true
        script.Parent.Text = ("DemonTrail - ON")
        Debounce = false
    end
end)

The second script was the one I followed a tutorial to do and it creates a trail for the player

local id = 8309369
local Trail = game.ServerStorage["SpeedDemonTrail"]

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:connect(function(char)
        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId, id) then
            local plrTrail = Trail:Clone()
            plrTrail.Parent = char.Torso
            plrTrail.Attachment0 = char.Head.FaceFrontAttachment
            plrTrail.Attachment1 = char.Torso.WaistBackAttachment
        end
    end)
end)
0
does an Object named 'SpeedDemonTrail' exist inside the serverstorage? If it does, then try using WaitForChild. Subsz 366 — 4y
0
It does exist inside ServerStorage. However when I hit play the first error I receive it's telling me "Blah SpeedDemonTrail is not a member of server storage". However everything else works properly ItsJZaid 45 — 4y
0
Try doing, game.ServerStorage:WaitForChild('SpeedDemonTrail') Subsz 366 — 4y
0
19:36:18.058 - Infinite yield possible on 'ServerStorage:WaitForChild("SpeedDemonTrail")'... Just got that while doing what you said ItsJZaid 45 — 4y
View all comments (4 more)
0
Could the issue possibly be that the trail is attached to the player and no longer exists in server storage by the time I try to enable/disable it? ItsJZaid 45 — 4y
0
That means that there is no object named SpeedDemonTrail inside the ServerStorage, are you sure SpeedDemonTrail is the exact name? Subsz 366 — 4y
0
Yes, I am 100% sure. Thing is that the script on the bottom needs to find SpeedDemonTrail in serverstorage. It finds the trail and displays the trail behind the player. However the script that enables and disables the trail says "SpeedDemonTrail" is not a valid member... when I click it but the spelling and names its the same ItsJZaid 45 — 4y
0
Well. Not when I click it but when I hit play it displays the trail behind the player, as meant to be. But when I click to disable, nothing happens. I open the script giving the error and says: 19:48:47.753 - SpeedDemonTrail is not a valid member of ServerStorage... However the other script uses the same line to find the trail in server storage and doesn't give the same issue? ItsJZaid 45 — 4y

1 answer

Log in to vote
1
Answered by
Subsz 366 Moderation Voter
4 years ago

Ok, alright so, the problem here is.. that you're trying to access ServerStorage through client.

what you instead want to do is, something like this.

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local Debounce = false

script.Parent.MouseButton1Click:Connect(function()
    local h = char.Torso.SpeedDemonTrail
    if Debounce == false then
        h.Enabled = false
        script.Parent.Text = ("DemonTrail - OFF") 
        Debounce = true
    else
        h.Enabled = true
        script.Parent.Text = ("DemonTrail - ON")
        Debounce = false
    end
end)
0
OH MY GOD THANK YOU SO MUCH! It works! I really appreciate it! ItsJZaid 45 — 4y
Ad

Answer this question