I have an issue with my script. I think it something to do with the "end" but I do not really know how to solve it.
All you did wrong is get the code in the wrong order! Oh and you you need to add a bracket on to the end) Just do it like this:
game.Players.PlayerAdded:Connect(function(player)
if player.Name == 'MateoGaming_YT' then
player.CharacterAdded:Connect(function(char)
local trail = game.ServerStorage.Trail:Clone()
trail.Parent = char.Head
--And all the rest of the trail bit
end)
end)
end)
If you need anymore help, feel free to ask!
Piggybacking off of Vigus Widdicombe-Gasson's answer. It looks like you corrected your script before taking the screenshot of your code.
The error that shows up in red in the Output window tells you how to figure out what's wrong here.
ServerScriptService.Script:14: ')' Expected (to close '(' at line 3) near <eof>
This error says that in ServerScriptService, there is a Script that threw an error on line 14.
This error is ')' Expected near <eof>. This means that a closing parenthesis was expected somewhere, but the script made it to the end of the file before it found it. Additionally, it tells us that the opening to this parenthesis was located on line 3.
So all you need to do to fix this is add a ) in the right place. Your code indenting makes it hard to see where the error is, but it should go after one of your end) statements.
I'll retype your code here for clarity :
game.Players.PlayerAdded:Connect(function(player)
if player.name == 'MateoGaming_YT' then
player.CharacterAdded:Connect(function(char) -- << this line needed a close parenthesis
-- be careful how you indent here, try to keep everything in the correct tab
local attachment0 = Instance.new("Attachement", char.Head)
local attachment1 = Instance.new("Attachement", char.HumanoidRootPart)
local trail = game.ServerStorage.Trail:Clone()
trail.Parent = char.Head
trail.Attachment0 = attachment0
trail.Attachment1 = attachment1
end) -- end player.CharacterAdded
end -- end if
end) -- end game.Players.PlayerAdded
Related
I made a zombie script with waves but then I got an error called "attempted to index nil with humanoid" so when I load it in my game I type in /console and the error keeps popping up, at first I thought my game had a virus but I fixed them all and there's still this error can someone help me even my friend can't help me. Thanks!
I have tried using various tools, asked my friends and also hired a Roblox Scripter for $1, but they couldn't fix it.
Here's my script for reference:
local spawns = script.Parent
local spawn_time = 10
while true do
wait(spawn_time)
for _,spwn in pairs(spawns:GetChildren()) do
if spwn:IsA('BasePart') then
local zombieCopy = game.ReplicatedStorage['Drooling Zombie']:Clone()
zombieCopy.Parent.HumanoidRootPart.CFrame = CFrame.new(spwn.Postiion + Vector3.new(0,3,0))
end
end
end
Any help would be greatly appreciated!
For those asking for what my idea is heres youtube link:
https://www.youtube.com/watch?v=klHXlim9Yuw
From what I understand, you are attempting to spawn a zombie model on the player when they spawn? Could you please also clarify where your script is, and what error you receive when you play the game and run the script? If anything is wrong in my response, please modify it accordingly or comment on what I have done wrong considering I haven't tested this script yet. From the script you have provided me, here's a somewhat better version of your script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local spawn = script.Parent
local duration = 10
local function summonZombie()
for _, spawn in pairs(spawn:GetChildren()) do
local zombieCopy = ReplicatedStorage['Drooling Zombie']:Clone()
zombieCopy.Parent.HumanoidRootPart.CFrame = CFrame.new(spawn.Position + Vector3.new(0,3,0))
end
end
while true do task.wait(duration) summonZombie() end
May I mention, there is a typo on the zombieCopy line, so that's something to point out. Please ensure you check your script for any silly mistakes like that before posting to SO.
One last thing, never use game.[Service] for calling in-game services like Workspace or Players. Instead use:
local Workspace = game:GetService("Workspace")
... not:
local Workspace = game.Workspace
Edit: sorry, I forgot to close the for statement.
I have updated the code above accordingly, thanks for the report.
I'm currently trying to make a level loading system for a game.
function love.filedropped(file)
ofile=io.open(file:getFilename(),"r")
io.input(ofile)
file:close
levelc=io.read()
for i=1,levelc do
levels[i]=io.read()
print levels[i]
end
levelc should be the first line of the file, and file:getFilename is the file to open (path included) the project gives an error message on startup, and i've used a similar structure before, but for an output. The error is at line 30, which is the levelc=io.read().
I've tried changing the name of the file pointer (it was "f" before, now "ofile") and i've tried using io.read("*l") instead of io.read() but same result.
EDITS:
-this is a love.filedropped(file)
-i need to open other files from a .txt later and i don't really understand how do do that
The parameter given by love.filedropped is a DroppedFile.
In your case helpful could be File:lines().
For example:
function love.filedropped(file)
-- Open for reading
file:open("r")
-- Iterate over the lines
local i = 0
for line in file:lines() do
i = i + 1
levels[i] = line
print(i, levels[i]) -- Notice the parentheses missing in your code
end
-- Close the file
file:close()
end
Notice that love2d usually only allows reading/writing files within the save or working directory. Dropped files are an exception.
Unrelated to this answer but things I noticed in your code:
Use locals, oFile should be local
file:close() required parentheses as its a function call
Same for the print
The filedropped callback has no end
You mentioned reading other files too, to do so, you can either:
Use love.filesystem.newFile and a similar approach as before
The recommended one-liner love.filesystem.lines
I've been trying to follow this youtube tutorial about a Sliding Door.
https://www.youtube.com/watch?v=8ZpD8t8kQC8&ab_channel=Terra
I followed all of the tutorial but the Door still doesn't open.
Here is the script:
animator = require(script.Parent.MainDoor.Animator)
script.Parent.Button.ClickDetector.MouseClick:Connect(function()
script.Parent.Button.CLickDetector.MaxActivationDistance = 0
wait(1)
script.Parent.MainDoor.Open:Play()
wait(0.1)
animator.DoorOpen:Play()
end)
Can someone please help me. Thanks.
Are there any errors in the output? Go to View > Output, to enable the window
I believe there might be a spelling error on line 4 'CLickDetector'. The l was not capital on line 3 so that might be throwing you an error since names are case-sensitive.
script.Parent.Button.CLickDetector.MaxActivationDistance = 0
Hope it helped!
In response to:
main door is not a valid member of model workspace.sliding door
Make sure that the main door is underneath the SlidingDoor model, and not outside it.
Paste this in the command bar(View > Command Bar), to find out what the parent is:
for _,v in ipairs(workspace:GetDescendants()) do
if string.lower(v.Name) == "maindoor" then
print("Found main door, parent is: " .. tostring(v.Parent))
end
end
The result will be shown in the output.
I was working on a kill-logs script that would when a person dies send data over a webhook ( plr.username has died!) But, I got stuck on an error that I can't really seem to fix '' CharacterAdded is not a valid member of Players '' on the first line of the code.
What I have tried: Checking spelling to make sure nothing is miss spelled, googling/digging around dev forums.
UPDATE: Started poking around the code a bit and got a new error, still can't fix it. I would need some help pretty please.
--start
local Players = game:GetService("Players")
local HttpService = game:GetService("HttpService")
local webhook = "removed the webhook link" -- webhook here
game.Players.PlayerAdded.
plr.CharacterAdded:Connect(function(character,plr)
character:WaitForChild("Humanoid").Died:Connect(function(msg)
local data = { --contet of data
content = msg;
username = plr.Name;
avatar_url = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&userId="..plr.UserId
}
HttpService:PostAsync(webhook, HttpService:JSONEncode(data))
end)
end)
print('nadam se da radi')
-- end
I can't find out how to fix this, if anybody can help me out fast I would appreciate it!
It looks like a chunk of your code was accidentally deleted.
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(character)
If you ever get stuck on trying to use a function or signal, you can always check out the docs online. They usually have code samples you can compare your code to.
I have looked at a number of other questions and their answers but I still don't seem to be able to fix this error message. I am writing a script which allows one player to change the face of another player. Due to the new ROBLOX update it is FE compatible therefore I will put both the Local Script and Server Script below even though the error is in the Server Script.
Local Script:
plr = script.Parent.Parent.Parent.NameInput.Text
script.Parent.MouseButton1Click:Connect(function()
script.Parent.RemoteEvent:FireServer(plr)
end)
Server Script:
faceid = script.Parent.FaceID.Value
script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr)
script.Parent.PName.Value = plr
local plrname = script.Parent.PName.Value
print (plrname)
game.Players[script.Parent.PName.Value].Character.Face.Texture = faceid
end)
Hierarchy:
This is the image of the hierarch of the GUI I am creating
Error Message: This is the image of the error I am receiving when I press the 'Test Face' button which is named 'One' in the explorer.
The server script is a bit messy as I have tried a few different ways to get around this error so if you think I could change anything or add/remove anything I would appreciate feedback on that. However, the main issue currently is the error I am getting on Line 4. There was also a previous error on Line 7 which said 'bad argument #2 to '?' (string expected, got Object)', but I would like to solve this issue first. Help with the scripts in general would be appreciated if deemed necessary by the people who attempt to help me.
Thank you in advance,
Rohan
Instead of using, plr you should get the name of the plr by using plr.Name.This way, you'll be telling the system the name of the player instead of getting the object.
faceid = script.Parent.FaceID.Value
script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr)
script.Parent.PName.Value = plr.Name -- edit was here
local plrname = script.Parent.PName.Value
print (plrname)
game.Players[script.Parent.PName.Value].Character.Face.Texture = faceid
end)